diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2020-07-05 14:05:04 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2020-07-05 14:05:04 +0200 |
commit | b722b45e5468af3e9405652b4ca57c10c376ba8b (patch) | |
tree | bbbce3bfcd56e07e965dc5f03baf4f33f4f72791 | |
parent | affe5b6b64d57e56eb14132fa67c8f9e3800af6c (diff) |
sfeed_atom: fix timezone, output if timestamp is set
Timezone should be GMT (as intended), do not convert to localtime.
-rw-r--r-- | sfeed_atom.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sfeed_atom.c b/sfeed_atom.c index 722a400..c5ea737 100644 --- a/sfeed_atom.c +++ b/sfeed_atom.c @@ -47,12 +47,6 @@ printfeed(FILE *fp, const char *feedname) line[--linelen] = '\0'; parseline(line, fields); - parsedtime = 0; - if (strtotime(fields[FieldUnixTimestamp], &parsedtime)) - continue; - if (!(tm = localtime(&parsedtime))) - err(1, "localtime"); - fputs("<entry>\n\t<title>", stdout); if (feedname[0]) { fputs("[", stdout); @@ -78,9 +72,15 @@ printfeed(FILE *fp, const char *feedname) xmlencode(fields[FieldEnclosure], stdout); fputs("\" />\n", stdout); } - fprintf(stdout, "\t<updated>%04d-%02d-%02dT%02d:%02d:%02dZ</updated>\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + + parsedtime = 0; + if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) && + (tm = gmtime(&parsedtime))) { + fprintf(stdout, "\t<updated>%04d-%02d-%02dT%02d:%02d:%02dZ</updated>\n", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + } + if (fields[FieldAuthor][0]) { fputs("\t<author><name>", stdout); xmlencode(fields[FieldAuthor], stdout); |