Namespace spl.time
This namespace contains components for handling times and timestamps.
For example, the following SPL functions provide some common operations on time:
- getTimestamp, to get the POSIX time, that is the number of seconds elapsed since the Epoch (00:00:00 UTC, January 1, 1970)
- time or gmtime, to convert POSIX time to broken-down time (using the Sys.tm type)
- toTimestamp to convert broken-down time to POSIX time
- strftime to convert broken-down time to a string representation
- strptime to convert a string representation to broken-down time.
By default this namespace is in scope for SPL programs, so no explicit use statement is required to use them.
Functions
- add(timestamp, float64): Add a time difference in seconds (as float64) to a timestamp.
- add(timestamp, int64): Add a time difference in nanoseconds (as int64) to a timestamp.
- createTimestamp(int64, uint32): Create a timestamp given the number of seconds and nanoseconds elapsed since the Epoch (00:00:00 UTC, January 1, 1970).
- createTimestamp(int64, uint32, int32): Create a timestamp given the number of seconds and nanoseconds elapsed since the Epoch (00:00:00 UTC, January 1, 1970), and a machine identifier that identifies the computer where the time measurement was taken.
- ctime(timestamp): Convert a timestamp to a date and time string, using the current timezone.
- day(timestamp): Extract the day of month from a timestamp, using the current timezone.
- dayOfWeek(timestamp): Extract the day of week from a timestamp, using the current timezone.
- dayOfYear(timestamp): Extract the day of year from a timestamp, using the current timezone.
- diffAsNanos(timestamp, timestamp): Compute the difference between two timestamps in nanoseconds (as int64).
- diffAsSecs(timestamp, timestamp): Compute the difference between two timestamps in seconds (as float64).
- fromDecimal128(decimal128): Convert to a timestamp a decimal128 value that preserves the precision of a timestamp, and represents the time as the number of seconds (including fractions) elapsed since the Epoch (00:00:00 UTC, January 1, 1970).
- getCPUCounterInNanoSeconds(): Obtain the CPU counter, which is an indication of relative time, in nanoseconds.
- getMachineId(timestamp): Extract the machine identifier from a timestamp.
- getNanoseconds(timestamp): Extract the part of a timestamp that represents the number of namoseconds elapsed since a whole number of seconds since the Epoch (00:00:00 UTC, January 1, 1970).
- getSeconds(timestamp): Extract the part of a timestamp that represents the number of whole seconds elapsed since the Epoch (00:00:00 UTC, January 1, 1970).
- getTimestamp(): Get the current wall clock time as a timestamp.
- getTimestampInSecs(): Get the current wall clock time as the number of seconds (including fractions) elapsed since the Epoch (00:00:00 UTC, January 1, 1970).
- gmday(timestamp): Extract the day of month from a timestamp, using the UTC timezone.
- gmdayOfWeek(timestamp): Extract the day of week from a timestamp, using the UTC timezone.
- gmdayOfYear(timestamp): Extract the day of year from a timestamp, using the UTC timezone.
- gmhour(timestamp): Extract the hour from a timestamp, using the UTC timezone.
- gmminute(timestamp): Extract the minute from a timestamp, using the UTC timezone.
- gmmonth(timestamp): Extract the month from a timestamp, using the UTC timezone.
- gmsecond(timestamp): Extract the second from a timestamp, using the UTC timezone.
- gmtime(timestamp, tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>): Convert a timestamp to a broken-down time (using the Sys.tm type), using the UTC timezone.
- gmyear(timestamp): Extract the year from a timestamp, using the UTC timezone.
- hour(timestamp): Extract the hour from a timestamp, using the current timezone.
- minute(timestamp): Extract the minute from a timestamp, using the current timezone.
- month(timestamp): Extract the month from a timestamp, using the current timezone.
- second(timestamp): Extract the second from a timestamp, using the current timezone.
- strftime(tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>, rstring): Convert a broken-down time (using the Sys.tm type) to a date and time string, using strftime.
- strptime(rstring, rstring, tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>, uint32): Convert a date and time string to a broken-down time (using the Sys.tm type), using strptime.
- time(timestamp, rstring, tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>): Convert a timestamp to a broken-down time (using the Sys.tm type), using a specified timezone.
- time(timestamp, tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>): Convert a timestamp to a broken-down time (using the Sys.tm type), using the current timezone.
- timeStringToTimestamp(rstring, rstring, boolean): Convert date and time strings into a timestamp, using the current timezone.
- timeStringToTimestamp(rstring, rstring, rstring, boolean): Convert date and time strings into a timestamp, using the specified timezone.
- timeStringToTimestamp(ustring, ustring, boolean): Convert date and time strings into a timestamp, using the current timezone.
- timeStringToTimestamp(ustring, ustring, ustring, boolean): Convert date and time strings into a timestamp, using the specified timezone.
- timeStringtoTimestamp(rstring, rstring, boolean): DEPRECATED.
- timeStringtoTimestamp(rstring, rstring, rstring, boolean): DEPRECATED.
- timeStringtoTimestamp(ustring, ustring, boolean): DEPRECATED.
- timeStringtoTimestamp(ustring, ustring, ustring, boolean): DEPRECATED.
- toDecimal128(timestamp): Convert a timestamp to a decimal128 value that preserves the precision of the timestamp, and represents the time as the number of seconds (including fractions) elapsed since the Epoch (00:00:00 UTC, January 1, 1970).
- toTimestamp(enum{YYYYMMDDhhmmss, YYYY_MM_DD_hh_mm_ss, MM_DD_YYYY_hh_mm_ss, DD_MM_YYYY_hh_mm_ss, YYYY_MM_DD_hh_mm_ss_mmm, MM_DD_YYYY_hh_mm_ss_mmm, DD_MM_YYYY_hh_mm_ss_mmm}, T): Converts a date and time string into a timestamp, using the current timezone.
- toTimestamp(enum{YYYYMMDDhhmmss, YYYY_MM_DD_hh_mm_ss, MM_DD_YYYY_hh_mm_ss, DD_MM_YYYY_hh_mm_ss, YYYY_MM_DD_hh_mm_ss_mmm, MM_DD_YYYY_hh_mm_ss_mmm, DD_MM_YYYY_hh_mm_ss_mmm}, T, T): Converts a date and time string into a timestamp, using the specified timezone.
- toTimestamp(tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>): Convert a broken-down time (using the Sys.tm type) into a timestamp.
- toTimestamp(tuple<int32 sec, int32 min, int32 hour, int32 mday, int32 mon, int32 year, int32 wday, int32 yday, int32 isdst, int32 gmtoff, rstring zone>, boolean): Convert a broken-down time (using the Sys.tm type) into a timestamp, using a parameter to specify whether to use the default timezone.
- year(timestamp): Extract the year from a timestamp, using the current timezone.