Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions sources/src/jdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ int main(int argc, char** argv)

struct jtm j;
struct tm g;
char *tmp_tm_zone;

struct jdate_action action = {0};

Expand Down Expand Up @@ -189,24 +190,40 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}

g.tm_hour = 0;
g.tm_hour = 12;
g.tm_min = 0;
g.tm_sec = 0;
g.tm_isdst = 0;
g.tm_gmtoff = 0;
tmp_tm_zone = getenv("TZ");
setenv("TZ", "UTC", 1);

t = mktime(&g);
if (tmp_tm_zone)
setenv("TZ", tmp_tm_zone, 1);
else
unsetenv("TZ");
} else if (action.gregorian) {
if (!jstrptime(action.gregorian_ptr, "%Y/%m/%d", &j)) {
fprintf(stderr, "Specify jalali date in the following format\n");
fprintf(stderr, "%%Y/%%m/%%d e.g. 1390/03/25\n");
exit(EXIT_FAILURE);
}

tmp_tm_zone = getenv("TZ");
setenv("TZ", "UTC", 1);
jalali_update(&j);
j.tm_hour = 0;
j.tm_hour = 12;
j.tm_min = 0;
j.tm_sec = 0;
j.tm_isdst = 0;
j.tm_gmtoff = 0;

t = jmktime(&j);
if (tmp_tm_zone)
setenv("TZ", tmp_tm_zone, 1);
else
unsetenv("TZ");
}

if (action.date) {
Expand Down