海鸥航迹

学习之笔记,好文之收集。

导航

Poco::DateTimeFormatter Tips

DateTimeFormatter::format bug?

Postby 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?

Postby 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.

posted on 2011-04-08 11:38  海天一鸥  阅读(859)  评论(0编辑  收藏  举报