TimeUtility¶
Namespace:
SideXP.Core
Miscellaneous functions for working with time and date values.
Methods¶
GetTimestamp(bool)¶
Gets the number of milliseconds elapsed since the Unix epoch (1970-01-01 UTC) for the current time.
Parameters
local: If enabled, computes the timestamp from local wall-clock time (Now) instead of UTC (UtcNow).
Returns
Returns the number of elapsed milliseconds.
GetTimestampSeconds(bool)¶
Gets the number of seconds elapsed since the Unix epoch (1970-01-01 UTC) for the current time.
Parameters
local: If enabled, computes the timestamp from local wall-clock time (Now) instead of UTC (UtcNow).
Returns
Returns the number of elapsed seconds.
ToTimestamp(DateTime)¶
Converts a given time into the number of elapsed milliseconds since the Unix epoch (1970-01-01 UTC). The DateTime's wall-clock value is used as-is (its DateTimeKind is not normalized), so pass a UTC value (e.g. UtcNow) for a true Unix timestamp.
Parameters
time: The time to convert.
Returns
Returns the number of elapsed milliseconds.
ToTimestampSeconds(DateTime)¶
Converts a given time into the number of elapsed seconds since the Unix epoch (1970-01-01 UTC).
Parameters
time: The time to convert.
Returns
Returns the number of elapsed seconds.