• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/time/time_to_iso8601.h"
6 
7 #include "base/check.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/time/time.h"
10 
11 namespace base {
12 
TimeToISO8601(const Time & t)13 std::string TimeToISO8601(const Time& t) {
14   Time::Exploded exploded;
15   t.UTCExplode(&exploded);
16   return StringPrintf("%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year,
17                       exploded.month, exploded.day_of_month, exploded.hour,
18                       exploded.minute, exploded.second, exploded.millisecond);
19 }
20 
21 }  // namespace base
22