LCS Number: | LCS-2016-11 |
---|---|
Version: | 2 |
Date: | 17-Nov-2016 |
Status: | Approved |
Author: | Rob Gaddi |
Source Doc: | DateTime |
More: | History |
Summary: | Provide system date/time mechanism in std.env |
package ENV is procedure STOP (STATUS: INTEGER); procedure STOP; procedure FINISH (STATUS: INTEGER); procedure FINISH; function RESOLUTION_LIMIT return DELAY_LENGTH; type DAYOFWEEK is ( SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY ); -- Calendar date/time, broken into parts. Second accomodates both -- single and double leap-seconds. Dayofyear accomodates leap days. -- Month 0 is January, 1 is February, 11 is December. Year is absolute -- in AD, 1900 represents the year 1900. -- type TIME_RECORD is record microsecond : INTEGER range 0 to 999_999 second : INTEGER range 0 to 61; minute : INTEGER range 0 to 59; hour : INTEGER range 0 to 23; day : INTEGER range 1 to 31; month : INTEGER range 0 to 11; year : INTEGER range 1 to 4095; weekday : DAYOFWEEK; dayofyear : INTEGER range 0 to 365; end record TIME_RECORD; -- Current local time broken into parts. -- Minimum legal resolution is 1 second. impure function LOCALTIME return TIME_RECORD; -- Current UTC time broken into parts. -- Minimum legal resolution is 1 second. impure function GMTIME return TIME_RECORD; -- Number of seconds since midnight, Jan 1 1970, UTC. -- Minimum legal resolution is 1 second. impure function EPOCH return REAL; -- Time conversion functions from epoch time. function LOCALTIME(TIMER: REAL) return TIME_RECORD; function GMTIME(TIMER: REAL) return TIME_RECORD; -- Time conversion function from time in parts. -- EPOCH and GMTIME accept TREC in local time. -- LOCALTIME accepts TREC in UTC. function EPOCH(TREC: TIME_RECORD) return REAL; function LOCALTIME(TREC: TIME_RECORD) return TIME_RECORD; function GMTIME(TREC: TIME_RECORD) return TIME_RECORD; -- Time increment/decrement. DELTA argument is in seconds. -- Returned TIME_RECORD is in local time or UTC per the TREC. function "+"(TREC: TIME_RECORD; DELTA: REAL) return TIME_RECORD; function "+"(DELTA: REAL; TREC: TIME_RECORD) return TIME_RECORD; function "-"(TREC: TIME_RECORD; DELTA: REAL) return TIME_RECORD; function "-"(DELTA: REAL; TREC: TIME_RECORD) return TIME_RECORD; -- Time difference in seconds. TR1, TR2 must both be in local -- time, or both in UTC. function "-"(TR1, TR2: TIME_RECORD) return REAL; -- Conversion between real seconds and VHDL TIME. SECONDS_TO_TIME -- will cause an error if the resulting REAL_VAL would be less than -- TIME'LOW or greater than TIME'HIGH. function TIME_TO_SECONDS(TIME_VAL: IN TIME) return REAL; function SECONDS_TO_TIME(REAL_VAL: IN REAL) return TIME; -- Convert TIME_RECORD to a string in ISO 8601 format. -- TO_STRING(x) => "1973-09-16T01:03:52" -- TO_STRING(x, 6) => "1973-09-16T01:03:52.000001" function TO_STRING(TREC: TIME_RECORD, FRAC_DIGITS: INTEGER range 0 to 6 := 0) return STRING; end package ENV;