Project

General

Profile

Actions

Support #7587

closed
BL RS

Local to UTC time

Support #7587: Local to UTC time

Added by Bradley Looy over 6 years ago. Updated over 5 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?

BL Updated by Bradley Looy over 6 years ago Actions #1

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();

RS Updated by Roel Standaert over 6 years ago Actions #2

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

RS Updated by Roel Standaert over 5 years ago Actions #3

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

Also available in: PDF Atom