Store a timezone
- Dominant language
- C++
- Stars
- 654
- Forks
- 178
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
This may be a question about how to use the library rather than an issue. If so, many thanks for a pointer in the right direction.
I receive strings representing time and then store absolute time (in protobufs as int64):
```
// Time zone is required by cctz::Parse(). It is only used if the
// formatted time does not include offset info.
const auto utc = cctz::UTCTimeZone();
const char kFmt[] = "%Y-%m-%dT%H:%M:%E*S%Ez";
system_clock::time_point this_time_point;
if (!cctz::Parse(kFmt, date_str, utc, &this_time_point)) {
cout << "Failed to parse time: " << date_str << endl;
return 0;
}
return system_clock::to_time_t(this_time_point);
```
This works great. From time to time, I need to know local time for the original source. That is, I've received something like `2015-12-23 10:55:09+0100` and stored `1450864509`. Now, in another process on another day, I see `1450864509` and want to recover `10:55` (i.e., for this absolute time, the corresponding local time was 10:55. For a concrete mental image, suppose I'm analysing when events correspond to lunchtime.
Of course, I can (outside of cctz) parse out the UTC offset and store that. I could also simply parse out the "HH:MM" string and store that. But those both seem quite wrong, and cctz seems well enough thought through that I'm guessing there's some way I haven't understood to persist an idea of a timezone.
And, if not, I suggest that this would be useful.
Contributor guide
Assessment
This issue has not been assessed yet.