aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkTime_Unix.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-05-01 07:06:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-01 07:06:23 -0700
commit0b9d4118ba4f3f1190c063492894e324c63e8fd8 (patch)
treed7b7faaa33d11420c02097b1653d08871f845f98 /src/ports/SkTime_Unix.cpp
parentd309e7aa0efa2d5dd7e7b1af97026fcd3a047e98 (diff)
SkTime: return timezone information; format in ISO-8601
Motivation: PDF/A metadata will need the creation date embedded in it. Also, GetDateTime returns local time in Win32. This now behaves the same as on Unix systems. BUG=skia:3110 Review URL: https://codereview.chromium.org/1109593002
Diffstat (limited to 'src/ports/SkTime_Unix.cpp')
-rw-r--r--src/ports/SkTime_Unix.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ports/SkTime_Unix.cpp b/src/ports/SkTime_Unix.cpp
index 6e305a16f6..2d5fa279b4 100644
--- a/src/ports/SkTime_Unix.cpp
+++ b/src/ports/SkTime_Unix.cpp
@@ -16,11 +16,15 @@ void SkTime::GetDateTime(DateTime* dt)
{
if (dt)
{
+ tzset(); // initialize timezone variable;
time_t m_time;
time(&m_time);
struct tm* tstruct;
tstruct = localtime(&m_time);
+ int offset = tstruct->tm_isdst == 1 ? 60 : 0;
+
// http://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html
+ dt->fTimeZoneMinutes = SkToS16(offset - timezone / 60);
dt->fYear = tstruct->tm_year + 1900;
dt->fMonth = SkToU8(tstruct->tm_mon + 1);
dt->fDayOfWeek = SkToU8(tstruct->tm_wday);