Hi Paul,
PowerBuilder has no system functions to do time interval calculations. Neither does PFC. I just checked PFC for PB 2017 including the DateTime service.
Basically, you need two functions:
- CalculateOverlap: returns the overlap[start; stop] between time intervals A[start; stop] and B[start; stop] using DateTime for all Start and Stop points in time
- HoursAfter: returns the distance between Start and Stop DateTimes measured in hours
- - OR - mix the two functions into one, e.g. CalculateOverlapHours. and thereby violate the single responsibility pricinple
Notes on prerequisites for calculating such intervals and durations:
- You must use DateTime instead of Time to avoid issues across midnight and for duration > 24 hours
- You must decide whether to ignore time zones or how to handle (EX: Convert to UTC)
- You must decide whether to ignore start/end daylight savings time or how to handle (EX: Convert to UTC)
- You must decide whether to ignore "leap seconds" or how to handle (EX: Convert to TAI {aka. Atomic Time} instead of UTC)
HTH /Michael
time interval 1: (starttime1 and endtime1) and time interval 2: (starttime2 and endtime2)
What is the overlap between these 2 different intervals.
Thanks for you prompt response