ImFusion SDK 4.3
ImFusion::DateTime Namespace Reference

Utility methods and classes related to date and time representation, including time zones. More...

Detailed Description

Utility methods and classes related to date and time representation, including time zones.

Classes

class  TimePoint
 Class representing a point in time, keeping track of UTC offsets and time zone name, if available. More...
 

Functions

uint64_t currentMillisecondsSinceEpochUtc ()
 Returns the total number of milliseconds since the configured epoch.
 
std::chrono::system_clock::time_point convertToTimePointFromMilliseconds (uint64_t millisecSinceEpochUtc)
 Converts a millisecond-based timestamp to a chrono time_point.
 
std::chrono::system_clock::time_point convertToTimePointFromSeconds (double secSinceEpochUtc)
 Converts a seconds-based timestamp to a chrono time_point.
 
std::chrono::system_clock::time_point convertToTimePointFromYMD (int year, int month, int day)
 Converts from year, month and day to a chrono time_point.
 
std::string formatTimePoint (std::chrono::system_clock::time_point tp, const std::string &fmt="%F %T")
 Helper function to format a given time point.
 
std::map< std::string, std::stringpossibleTimeZones (std::chrono::system_clock::time_point utc, std::chrono::minutes offset)
 Helper function to query all known time zones for a given UTC date and an offset.
 
std::vector< std::stringpossibleTimeZoneAbbr (std::chrono::system_clock::time_point utc, std::chrono::minutes offset)
 Helper function to query all unique known time zone abbreviation for a given UTC date and an offset.
 
std::optional< std::chrono::system_clock::time_point > convertToTimezoneFromUTC (std::chrono::system_clock::time_point utc, const std::string &timezone)
 Helper function to convert a time in UTC to a local time in the timezone specified by the timezoneAbbrev parameter.
 

Function Documentation

◆ convertToTimePointFromMilliseconds()

std::chrono::system_clock::time_point convertToTimePointFromMilliseconds ( uint64_t millisecSinceEpochUtc)

Converts a millisecond-based timestamp to a chrono time_point.

(convention is used in stream data and the timestamp data components)

◆ convertToTimePointFromSeconds()

std::chrono::system_clock::time_point convertToTimePointFromSeconds ( double secSinceEpochUtc)

Converts a seconds-based timestamp to a chrono time_point.

(convention is used for images and tracking samples)

◆ convertToTimePointFromYMD()

std::chrono::system_clock::time_point convertToTimePointFromYMD ( int year,
int month,
int day )

Converts from year, month and day to a chrono time_point.

Parameters
yearAllowed value range is [1900, 2261]
monthAllowed value range is [1, 12]
dayAllowed value range is [1, 31]
Exceptions
std::runtime_errorif the input values cannot be converted

◆ formatTimePoint()

std::string formatTimePoint ( std::chrono::system_clock::time_point tp,
const std::string & fmt = "%F %T" )

Helper function to format a given time point.

Omits fractions of seconds. Allowed format strings are described here: https://howardhinnant.github.io/date/date.html#duration_io, "to_stream formatting" section

◆ possibleTimeZones()

std::map< std::string, std::string > possibleTimeZones ( std::chrono::system_clock::time_point utc,
std::chrono::minutes offset )

Helper function to query all known time zones for a given UTC date and an offset.

The returned map maps from IANA zone names to the standard abbreviation using for display, for instance Europe/Berlin to CET.

◆ possibleTimeZoneAbbr()

std::vector< std::string > possibleTimeZoneAbbr ( std::chrono::system_clock::time_point utc,
std::chrono::minutes offset )

Helper function to query all unique known time zone abbreviation for a given UTC date and an offset.

For a winter date and offset +1h, it will for instance return, possibly among others, the following: +01, CET, MET, WAT.

◆ convertToTimezoneFromUTC()

std::optional< std::chrono::system_clock::time_point > convertToTimezoneFromUTC ( std::chrono::system_clock::time_point utc,
const std::string & timezone )

Helper function to convert a time in UTC to a local time in the timezone specified by the timezoneAbbrev parameter.

If the timezone cannot be identified by the abbreviation, the optional is null.

Search Tab / S to search, Esc to close