C++ counterparts of SPL native functions that deal with time operations. More...


Detailed Description

C++ counterparts of SPL native functions that deal with time operations.

Common operations:


Enumeration Type Documentation

Time Conversion Types Supported formats:

Enumerator:
YYYYMMDDhhmmss 

"YYYYMMDDhhmmss"

YYYY_MM_DD_hh_mm_ss 

"YYYY-MM-DD hh:mm:ss" (any separator can be used)

MM_DD_YYYY_hh_mm_ss 

"MM-DD-YYYY hh:mm:ss" (any separator can be used)

DD_MM_YYYY_hh_mm_ss 

"DD-MM-YYYY hh:mm:ss" (any separator can be used)

YYYY_MM_DD_hh_mm_ss_mmm 

"YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)

MM_DD_YYYY_hh_mm_ss_mmm 

"MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)

DD_MM_YYYY_hh_mm_ss_mmm 

"DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)


Function Documentation

Create a timestamp.

Parameters:
Returns:
A timestamp (sec, nanos).

Create a timestamp.

Parameters:
Returns:
A timestamp (sec, nanos, mid).

Compute the difference between two timestamps (in nanoseconds as int64).

Note:
Valid for ranges of 2^63 nanoseconds (292.47 years).
Parameters:
Returns:
The difference ts1 - ts2 in nanoseconds.

Compute the difference between two timestamps (in seconds as float64).

Note:
Differences of less than 104.24 days retain nanosecond accuracy. Larger differences retain less accuracy.
Parameters:
Returns:
The difference ts1 - ts2 in seconds.

Add a time difference to a timestamp (in seconds as float64).

Parameters:
Returns:
The timestamp for ts + diff.

Add a time difference to a timestamp (in nanoseconds as int64).

Parameters:
Returns:
The timestamp for ts + diff.

Extract the seconds from a timestamp.

Parameters:
Returns:
The 'seconds' part of the timestamp.

Extract the nanoseconds from a timestamp.

Parameters:
Returns:
The 'nanoseconds' part of the timestamp.

Extract the machine id from a timestamp.

Parameters:
Returns:
The 'machineId' part of the timestamp.

Convert a timestamp to a decimal128 value.

Parameters:
Returns:
Timestamp as a decimal128 value (preserve all bits).

Convert a decimal128 value to a timestamp.

Parameters:
Returns:
A timestamp that represents the same time.

Obtain the CPU counter, which is an indication of relative time in nanoseconds.

Note:
This function cannot be used for reliable time measurements across multiple processors.
Returns:
The current processor CPU counter in nanoseconds.

Get the current wall clock time.

Returns:
Time since the Epoch (00:00:00 UTC, January 1, 1970).
Note:
This function uses gettimeofday system call on Linux.
Exceptions:

Get the current wall clock time in seconds (fractional).

Returns:
Time since the Epoch (00:00:00 UTC, January 1, 1970).
Note:
This function uses gettimeofday system call on Linux.
Exceptions:

Convert a timestamp to broken-down time (Sys.tm), using the current timezone.

Parameters:

Convert a timestamp to broken-down time (Sys.tm), using a specified timezone.

Parameters:

Convert a timestamp to broken-down time (Sys.tm) using UTC timezone.

Parameters:

Convert a broken-down time (Sys.tm) into a timestamp containing the time since the Epoch.

Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Convert a broken-down time (Sys.tm) into a timestamp containing the time since the Epoch. Additional parameter to specify using default time zone

Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Convert broken-down time (Sys.tm) to a date and time string.

Parameters:
Returns:
String representation of date and time.
Note:
This function is POSIX compliant, and uses the current locale.

Convert a date and time string to broken-down time (Sys.tm).

Parameters:
Note:
This function is POSIX compliant, and uses the current locale.

Extract the year from the time, using the current timezone.

Parameters:
Returns:
The year component of the time.
Note:
This function uses the POSIX localtime_r routine.

Extract the month from the time, using the current timezone.

Parameters:
Returns:
The month component of the time (in the range [0,11]).
Note:
This function uses the POSIX localtime_r routine.

Extract the day of month from the time, using the current timezone.

Parameters:
Returns:
The day component of the time (in the range [1,31]).
Note:
This function uses the POSIX localtime_r routine.

Extract the hour from the time, using the current timezone.

Parameters:
Returns:
The hour component of the time (in the range [0,23]).
Note:
This function uses the POSIX localtime_r routine.

Extract the minute from the time, using the current timezone.

Parameters:
Returns:
The minute component of the time (in the range [0,59]).
Note:
This function uses the POSIX localtime_r routine.

Extract the second from the time, using the current timezone.

Parameters:
Returns:
The second component of the time (in the range [0,61]).
Note:
This function uses the POSIX localtime_r routine.

Extract the day of year from the time, using the current timezone.

Parameters:
Returns:
The day component of the time (in the range [0,365]).
Note:
This function uses the POSIX localtime_r routine.

Extract the day of week from the time, using the current timezone.

Parameters:
Returns:
The day component of the time (in the range [0,6], 0 = Sunday).
Note:
This function uses the POSIX localtime_r routine.

Extract the year from the time, using the UTC timezone.

Parameters:
Returns:
The year component of the time.
Note:
This function uses the POSIX gmtime_r routine.

Extract the month from the time, using the UTC timezone.

Parameters:
Returns:
The month component of the time (in the range [0,11]).
Note:
This function uses the POSIX gmtime_r routine.

Extract the day of month from the time, using the UTC timezone.

Parameters:
Returns:
The day component of the time (in the range [1,31]).
Note:
This function uses the POSIX gmtime_r routine.

Extract the hour from the time, using the UTC timezone.

Parameters:
Returns:
The hour component of the time (in the range [0,23]).
Note:
This function uses the POSIX gmtime_r routine.

Extract the minute from the time, using the UTC timezone.

Parameters:
Returns:
The minute component of the time (in the range [0,59]).
Note:
This function uses the POSIX gmtime_r routine.

Extract the second from the time, using the UTC timezone.

Parameters:
Returns:
The second component of the time (in the range [0,61]).
Note:
This function uses the POSIX gmtime_r routine.

Extract the day of year from the time, using the UTC timezone.

Parameters:
Returns:
The day component of the time (in the range [0,365]).
Note:
This function uses the POSIX gmtime_r routine.

Extract the day of week from the time, using the UTC timezone.

Parameters:
Returns:
The day component of the time (in the range [0,6], 0 = Sunday).
Note:
This function uses the POSIX gmtime_r routine.

Convert a time value to a date and time string, using the current timezone.

Parameters:
Returns:
String representation of date and time in the form "Wed Jun 30 21:49:08 1993\n", using the C locale.

Converts date and time strings into a timestamp containing the time since the Epoch, using the current timezone.

Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts date and time strings into a timestamp containing the time since the Epoch, using the current timezone.

Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts date and time strings into a timestamp containing the time since the Epoch, using the specified timezone.

Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts date and time strings into a timestamp containing the time since the Epoch, using the specified timezone.

Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the current time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the current time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the current time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the current time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the specified time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the specified time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the specified time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

Converts a date and time string into a timestamp containing the time since the Epoch, using the specified time zone. Supported formats:

  • Sys.YYYYMMDDhhmmss: "YYYYMMDDhhmmss"
  • Sys.YYYY_MM_DD_hh_mm_ss: "YYYY-MM-DD hh:mm:ss" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss: "MM-DD-YYYY hh:mm:ss" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss: "DD-MM-YYYY hh:mm:ss" (any separator can be used)
  • Sys.YYYY_MM_DD_hh_mm_ss_mmm: "YYYY-MM-DD hh:mm:ss.mmm" (any separator can be used)
  • Sys.MM_DD_YYYY_hh_mm_ss_mmm: "MM-DD-YYYY hh:mm:ss.mmm" (any separator can be used)
  • Sys.DD_MM_YYYY_hh_mm_ss_mmm: "DD-MM-YYYY hh:mm:ss.mmm" (any separator can be used)
    Parameters:
    Returns:
    Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

DEPRECATED. Please replace with timeStringToTimestamp. Converts date and time strings into a timestamp containing the time since the Epoch, using the specified timezone.

Note:
DEPRECATED. Please replace with timeStringToTimestamp.
Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

DEPRECATED. Please replace with timeStringToTimestamp. Converts date and time strings into a timestamp containing the time since the Epoch, using the current timezone.

Note:
DEPRECATED. Please replace with timeStringToTimestamp.
Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

DEPRECATED. Please replace with timeStringToTimestamp. Converts date and time strings into a timestamp containing the time since the Epoch, using the current timezone.

Note:
DEPRECATED. Please replace with timeStringToTimestamp.
Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).

DEPRECATED. Please replace with timeStringToTimestamp. Converts date and time strings into a timestamp containing the time since the Epoch, using the specified timezone.

Note:
DEPRECATED. Please replace with timeStringToTimestamp.
Parameters:
Returns:
Seconds since the Epoch (00:00:00 UTC, January 1, 1970).