-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: libbson
-
(copied to CRM)
It looks like the C driver currently doesn't provide a public function for converting from BSON dates to ISO8601 strings. It would be helpful to provide a standard public cross-platform function via the driver API, as standard C library functions like gmtime() do not consistently support dates before the Unix epoch.
For example, the Windows implementation of the `gmtime()` function currently does not support dates earlier than 1970:
If sourceTime represents a date before midnight, January 1, 1970, *gmtime* returns *NULL*. There is no error return.
A suggested approach on Windows would be to fallback to SYSTEMTIME using the Windows API instead of C API: https://docs.microsoft.com/en-us/windows/desktop/Intl/retrieving-time-and-date-information (GetTimeFormatEx, GetDateFormatEx).