Convert time_t to tm at a specific time

The function localtime_rconverts the timestamp time_tto struct tmin the current time zone.

How can you convert UTC time_tto struct tmin a different time zone, for example. by the time, for example, in Sydney, Australia, taking into account daylight saving time and everything else, and without affecting use localtimein other parts of the program?

+4
source share
1 answer

The NetBSD C runtime library includes some functions for processing arbitrary time zones (see NetBSD 6.1.5 - help page for ctime (section netbsd 3). To get similar functions in other projects, you can use the code from IANA Time Zone Database , in particular, her localtime.c, private.hand tzfile.h.

0
source

Source: https://habr.com/ru/post/1628537/


All Articles