| 1 | == hetTime.py == |
| 2 | |
| 3 | Some useful tools for dealing with time at the HET in all its different formats |
| 4 | |
| 5 | ''' Definitions ''' |
| 6 | |
| 7 | * unix time -- the number of seconds since the epoch. The epoch |
| 8 | defined as 00:00:00 UTC, January 1, 1970. This number |
| 9 | may be a floating point value. |
| 10 | |
| 11 | * index time -- The tracker definition of the time of day. Index time |
| 12 | is reset to 0.0 at 1800 UT hours or 12 noon CST (1300 CDT). |
| 13 | There is no information contained here that might indicate |
| 14 | which day this index time occurred on. This number may be |
| 15 | a floating point value. |
| 16 | |
| 17 | 0000 hours UT == 00000 secs UT == 0600 hours index == 21600 seconds index |
| 18 | |
| 19 | 0600 hours UT == 21600 secs UT == 1200 hours index == 43200 seconds index |
| 20 | |
| 21 | 1200 hours UT == 43200 secs UT == 1800 hours index == 64800 seconds index |
| 22 | |
| 23 | 1800 hours UT == 64800 secs UT == 2400 hours index == 86400 seconds index (0000) |
| 24 | |
| 25 | (0000) 2400 hours UT == 86400 secs UT == 0600 hours index == 21600 seconds index |
| 26 | |
| 27 | * ISO time -- an ISO-8601 string of the format YYYY-MM-DDThh:mm:ss.mmmmmm, where YYYY is |
| 28 | the four digit year, MM is the two digit month (starts at 01), DD is the |
| 29 | two digit day (starts at 01), hh is the two digit hour, mm is the two |
| 30 | digit minute, ss is the two digit second, and mmmmmm is the fractional |
| 31 | part of the second. |
| 32 | |
| 33 | * datetime -- a python datetime.datetime() object. This is the intermediate |
| 34 | object through which the time conversion routines work. It is also |
| 35 | a value which Python can work with. See the documentation for |
| 36 | the datetime package within Python |
| 37 | |
| 38 | * ''' Future Plans. ''' |
| 39 | |
| 40 | Convert to object hetTime(), subclass of datetime, which takes an index time, unix time, |
| 41 | datetime object or ISO string at instantion. added functions hetTime.indexTime(), hetTime.unixTime(), |
| 42 | hetTime.ISOtime() to return time in different format. ISOtime and unixTime contain year/mon/day information |
| 43 | but index time does not. Use the current year/mon/day unless there is a specified year/mon/day at instantation. |
| 44 | |
| 45 | hetTime(index|unix|iso, year=now.year, mon=year.mon, day=now.day) |
| 46 | |
| 47 | * Functions |
| 48 | 1. ISO_To_DT(isoStr) |
| 49 | 2. DT_To_ISO(dt) |
| 50 | 3. Index_To_DT(ind) |
| 51 | 4. DT_To_Index(dt) |
| 52 | 5. Unix_To_DT(utime) |
| 53 | 6. DT_To_Unix(dt) |