Skip to content

Commit

Permalink
vcardtime.c: use icalgmtime_r() rather than gmtime()
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmurchison committed Apr 21, 2024
1 parent e838d0b commit 64198f2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/libicalvcard/vcardtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "vcardtime.h"
#include "icalmemory.h"
#include "icaltime.h"

#include <limits.h>
#include <stdio.h>
Expand All @@ -32,9 +33,20 @@ vcardtimetype vcardtime_null_datetime(void)
vcardtimetype vcardtime_current_utc_time(void)
{
time_t now = time(0);
struct tm *t = gmtime(&now);
vcardtimetype tt = { t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec, 0 };
struct tm t;
vcardtimetype tt;

if (!icalgmtime_r(&now, &t)) {
return vcardtime_null_datetime();
}

tt.year = t.tm_year + 1900;
tt.month = t.tm_mon + 1;
tt.day = t.tm_mday;
tt.hour = t.tm_hour;
tt.minute = t.tm_min;
tt.second = t.tm_sec;
tt.utcoffset = 0;

return tt;
}
Expand Down

0 comments on commit 64198f2

Please sign in to comment.