Project

General

Profile

Actions

Support #7587

closed

Local to UTC time

Added by Bradley Looy over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Low
Assignee:
Roel Standaert
Target version:
-
Start date:
05/28/2020
Due date:
% Done:

0%

Estimated time:

Description

If the user enters a date & time, say 5/28/2020 15:30. What is the best method for converting that local datetime to UTC?

Actions #1

Updated by Bradley Looy over 4 years ago

Would this be the preferred method?

WLocalDateTime local_datetime;

local_datetime.setDateTime(WDate(2020, 05, 28), WTime(15, 30, 0));

WDateTime utc_datetime = local_datetime.toUTC();

Actions #2

Updated by Roel Standaert over 4 years ago

That should work if the current locale is set to the right timezone. You can set it like this:

locale.setTimeZone(date::locate_zone(timeZoneName));

On Linux that should just work, because it comes with its own copy of the IANA time zone database. On Windows, there is a time zone database, but it is not compatible with our implementation. You'll have to download the time zone database instead: https://www.iana.org/time-zones. There are some more details in the locale feature example: https://github.com/emweb/wt/tree/master/examples/feature/locale

Actions #3

Updated by Roel Standaert over 3 years ago

  • Description updated (diff)
  • Status changed from New to Closed
Actions

Also available in: Atom PDF