K
KW
Hi all,
Appreciate if someone can help me out on this.
Currently, I have a tm structure holding information of the UTC time,
which is very likely to be in the past, meaning not the current time.
So, let's say I'm in CST(-6) now, and I want to know the equivalent
local time of that tm structure, how do I do that taking into
consideration daylight savings adjustments?
Well, I have gathered some info:
mktime() will convert the tm structure and return a time_t object, but
this time_t returned is of the local time, not UTC.
localtime() takes in a time_t argument(of UTC) and returns a tm
structure pointing to the local time. This is actually what I desire,
but, I still can't seem to translate the tm structure of the UTC time
to a time_t (UTC) data type.
gmtime() also takes in one argument of time_t (UTC) but returns a tm
structure pointing to the UTC time.
In short:
local tm -> mktime() -> local time_t
UTC time_t -> localtime() -> local tm
UTC time_t -> gmtime() -> UTC tm
So, what I am looking for is:
UTC tm -> ???() -> UTC time_t
Thanks in advance!
KW
Appreciate if someone can help me out on this.
Currently, I have a tm structure holding information of the UTC time,
which is very likely to be in the past, meaning not the current time.
So, let's say I'm in CST(-6) now, and I want to know the equivalent
local time of that tm structure, how do I do that taking into
consideration daylight savings adjustments?
Well, I have gathered some info:
mktime() will convert the tm structure and return a time_t object, but
this time_t returned is of the local time, not UTC.
localtime() takes in a time_t argument(of UTC) and returns a tm
structure pointing to the local time. This is actually what I desire,
but, I still can't seem to translate the tm structure of the UTC time
to a time_t (UTC) data type.
gmtime() also takes in one argument of time_t (UTC) but returns a tm
structure pointing to the UTC time.
In short:
local tm -> mktime() -> local time_t
UTC time_t -> localtime() -> local tm
UTC time_t -> gmtime() -> UTC tm
So, what I am looking for is:
UTC tm -> ???() -> UTC time_t
Thanks in advance!
KW