diff options
author | 2015-05-01 07:06:23 -0700 | |
---|---|---|
committer | 2015-05-01 07:06:23 -0700 | |
commit | 0b9d4118ba4f3f1190c063492894e324c63e8fd8 (patch) | |
tree | d7b7faaa33d11420c02097b1653d08871f845f98 /src/core | |
parent | d309e7aa0efa2d5dd7e7b1af97026fcd3a047e98 (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/core')
-rw-r--r-- | src/core/SkTime.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/SkTime.cpp b/src/core/SkTime.cpp new file mode 100644 index 0000000000..b8e42365ef --- /dev/null +++ b/src/core/SkTime.cpp @@ -0,0 +1,24 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkString.h" +#include "SkTime.h" + +void SkTime::DateTime::toISO8601(SkString* dst) const { + if (dst) { + int timeZoneMinutes = SkToInt(fTimeZoneMinutes); + char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-'; + int timeZoneHours = abs(timeZoneMinutes) / 60; + timeZoneMinutes = abs(timeZoneMinutes) % 60; + dst->printf("%04u-%02u-%02uT%02u:%02u:%02u%c%02d:%02d", + static_cast<unsigned>(fYear), static_cast<unsigned>(fMonth), + static_cast<unsigned>(fDay), static_cast<unsigned>(fHour), + static_cast<unsigned>(fMinute), + static_cast<unsigned>(fSecond), timezoneSign, timeZoneHours, + timeZoneMinutes); + } +} |