Here is my code:
#include <time.h>
#include <stdio.h>
time_t my_timegm (struct tm *tm, char *tz_offset);
int
main (void)
{
struct tm time_tm;
time_t start_timet, end_timet;
time_tm.tm_sec = 0;
time_tm.tm_min = 0;
time_tm.tm_hour = 0;
time_tm.tm_mday = 1;
time_tm.tm_mon = 0;
time_tm.tm_year = 2023 - 1900;
time_tm.tm_isdst = -1;
start_timet = my_timegm (&time_tm, "Etc/GMT-6");
printf ("\n%li ", start_timet);
start_timet = my_timegm (&time_tm, "America/Chicago");
printf ("\n%li ", start_timet);
}
And my_timegm is
#include <time.h>
#include <stdlib.h>
time_t
my_timegm (struct tm *tm, char *tz_offset)
{
time_t ret;
char *tz;
tz = getenv ("TZ");
setenv ("TZ", tz_offset, 1);
tzset ();
ret = mktime (tm);
if (tz)
setenv ("TZ", tz, 1);
else
unsetenv ("TZ");
tzset ();
return ret;
}
The output is:
1672509600
1672552800
Why is there a 43200 seconds (12 hours) difference? Or, why is GMT-6 not the same as America/Chicago, which is UTC-6?