APEL times and dates
APEL works in UTC, which is both simple and convenient (because we happen to be in the UK).
Epoch times are also convenient, because they are all in UTC and you don't have to convert. This means that whenever we get a message, we can rely on the timezone being correct and the conversion being automatic. In many of the batch system log files, the dates are in epoch times, presumably for the same reason.
The CAR uses ISO 8601 dates and time durations. This presents a little bit more difficulty.
ISO 8601 Dates
The ISO 8601 dates are quite permissive, so there are a lot of possibilities. I'm using python-dateutil to parse them, which should work fine.
There is one caveat - if there is no time zone information provided in the date, I'm assuming that the date and time are in UTC - there's not much else I can do.
ISO 8601 Durations
These aren't that widely used, so there aren't standard libraries to parse them.
We are accepting durations of the form:
- The P denotes 'period' and must be at the start of the string.
- Y, M, W, D, H, M, S stand for year, month, week, day, hour, minute and second respectively.
- T (for time) sits between date values and time values so that you can distinguish months from minutes. So
P1MTis one month, but
PT1Mis one minute.
- All durations are optional and you can use any combination you choose.
- Our calculations of month and year are approximate, so if you want to be exact use days, hours, minutes and seconds, eg
P235DT14H7M12S. This is the same as
We treat one year as 365 * 24 * 60 * 60 = 31536000 seconds. We treat one month as 31536000 / 12 = 2628000 seconds.