且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Poco::DateTimeFormatter Tips

更新时间:2022-09-13 22:06:56


DateTimeFormatter::format bug?

Poco::DateTimeFormatter Tipsby sgsoft » 25 Oct 2010, 18:07

below code :

Code: Select all
   int tzd=Poco::Timezone::tzd();
   cout<<tzd<<endl;
   Poco::Timestamp now;
        cout<<Poco::DateTimeFormatter::format(now,Poco::DateTimeFormat::SORTABLE_FORMAT)<<endl;   //test1
   cout<<Poco::DateTimeFormatter::format(now,Poco::DateTimeFormat::SORTABLE_FORMAT,tzd)<<endl;  //test2

the test1 is same to test2 ? maybe the tsz parameter has no effect. why?
sgsoft
Posts: 5
Joined: 03 Jul 2010, 12:26

Top


Re: DateTimeFormatter::format bug?

Poco::DateTimeFormatter Tipsby guenter » 27 Oct 2010, 16:22

DateTimeFormatter does not do local time calculation. The optional tzd is only used when the respective format specifier (%z or %Z) is present. To format a proper local time, pass an instance of Poco::LocalDateTime to DateTimeFormatter.


本文转自海天一鸥博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2011/04/08/2009226.html,如需转载请自行联系原作者