Wtx ~ Wt Extension Library
WtxLib
Setting the proper TimeZone at application start-up

In order to use Wt::WLocalDateTime, you must set in a proper time-zone inside the application locale. The following codes will aid in setting the locale with a proper time-zone and perhaps custom date formatting and so on.

·
148 #include <chrono>
149 #include <Wt/Date/tz.h>
150
151 //
152 // set the time-zone to the proper format
154 //
155 auto loc = locale();
156
157 auto tz = date::locate_zone( environment().timeZoneName() );
158
159 loc.setTimeZone( tz );
160
161 std::cout << __FILE__ << ":" << __LINE__
162 << " tzn:" << environment().timeZoneName()
163 << " tzo:" << environment().timeZoneOffset().count()
164 << " tz:" << tz
165 << " loc:" << loc.name()
166 << " ltz:" << loc.timeZone()-> name()
167 << std::endl;
168
151 //
152 // set the date format to regular american
154 //
169 loc.setDateFormat( "MM/dd/yyyy" );
170 setLocale( loc );
171
172 } // endvoid MyProject::AppBase::init( )

· ·