CCTZ 2.0: cctz::lookup(..) vs cctz::format(..)

69 views
Skip to first unread message

Susanne Meyer

unread,
Apr 8, 2016, 3:13:42 AM4/8/16
to cctz
Is it true that it is not recommended to use cctz::lookup(..) and always preferred to use cctz::format(..) instead?
But if I want to store the results (year, month, day...offset, isDST, abbr) in integer, double, bool and string variables. How can I do this using cctz::format(..)?

Is there a way to do the following example with cctz::format(..)? If so can you please give a short example?

int main()
{
cctz::time_zone lax;
load_time_zone("America/Los_Angeles", &lax);

const auto tp = cctz::convert(cctz::civil_second(2015, 9, 22, 9, 0, 0), lax);

cctz::time_zone nyc;
load_time_zone("America/New_York", &nyc);

const auto al = nyc.lookup(tp);

int year, month, day, hour, minute, second;
double UT_Offset;
bool isDST;
std::string abbr;

year      = al.cs.year();
month      = al.cs.month();
day          = al.cs.day();
hour      = al.cs.hour();
minute      = al.cs.minute();
second      = al.cs.second();
UT_Offset = al.offset / 3600.0;
isDST      = al.is_dst;
abbr      = al.abbr;
}

Greg Miller

unread,
Apr 8, 2016, 6:19:52 AM4/8/16
to Susanne Meyer, cctz
No, it is fine to use cctz::time_zone::lookup().

--
https://github.com/google/cctz
---
You received this message because you are subscribed to the Google Groups "cctz" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cctz+uns...@googlegroups.com.
To post to this group, send email to cc...@googlegroups.com.
Visit this group at https://groups.google.com/group/cctz.
To view this discussion on the web visit https://groups.google.com/d/msgid/cctz/bf442396-36bc-4ce8-a2b7-098cf7f26e64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages