1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "SkString.h"
9 #include "SkTime.h"
10 
toISO8601(SkString * dst) const11 void SkTime::DateTime::toISO8601(SkString* dst) const {
12     if (dst) {
13         int timeZoneMinutes = SkToInt(fTimeZoneMinutes);
14         char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-';
15         int timeZoneHours = abs(timeZoneMinutes) / 60;
16         timeZoneMinutes = abs(timeZoneMinutes) % 60;
17         dst->printf("%04u-%02u-%02uT%02u:%02u:%02u%c%02d:%02d",
18                     static_cast<unsigned>(fYear), static_cast<unsigned>(fMonth),
19                     static_cast<unsigned>(fDay), static_cast<unsigned>(fHour),
20                     static_cast<unsigned>(fMinute),
21                     static_cast<unsigned>(fSecond), timezoneSign, timeZoneHours,
22                     timeZoneMinutes);
23     }
24 }
25