Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert time_point_sec to string should explicit the zone info #34

Open
jjnetcn opened this issue Oct 25, 2018 · 0 comments
Open

convert time_point_sec to string should explicit the zone info #34

jjnetcn opened this issue Oct 25, 2018 · 0 comments

Comments

@jjnetcn
Copy link

jjnetcn commented Oct 25, 2018

time_point_sec::to_iso_string use boost::ptime to convert time_t to ios 8601 time string format with:
const auto ptime = boost::posix_time::from_time_t( time_t( sec_since_epoch() ) );
return boost::posix_time::to_iso_extended_string( ptime );
Note ptime has drop the zone info, and not strict compatible iso 8610.
it convert to string without zone and can be understand in context,
(sometimes is UTC or sometimes local zone with utc_to_local...)

https://en.wikipedia.org/wiki/ISO_8601, it says
"If no UTC relation information is given with a time representation, the time is assumed to be in local time. ...", it confused, i thank should append 'Z' to indicate UTC zone, and change code:
return boost::posix_time::to_iso_extended_string( ptime )+"Z";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant