1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef GOOGLE_APIS_DRIVE_TIME_UTIL_H_ 6#define GOOGLE_APIS_DRIVE_TIME_UTIL_H_ 7 8#include <string> 9 10#include "base/strings/string_piece.h" 11 12namespace base { 13class Time; 14} // namespace base 15 16namespace google_apis { 17namespace util { 18 19// Parses an RFC 3339 date/time into a base::Time, returning true on success. 20// The time string must be in the format "yyyy-mm-ddThh:mm:ss.dddTZ" (TZ is 21// either '+hh:mm', '-hh:mm', 'Z' (representing UTC), or an empty string). 22bool GetTimeFromString(const base::StringPiece& raw_value, base::Time* time); 23 24// Formats a base::Time as an RFC 3339 date/time (in UTC). 25// If |time| is null, returns "null". 26std::string FormatTimeAsString(const base::Time& time); 27 28// Formats a base::Time as an RFC 3339 date/time (in localtime). 29// If |time| is null, returns "null". 30std::string FormatTimeAsStringLocaltime(const base::Time& time); 31 32} // namespace util 33} // namespace google_apis 34 35#endif // GOOGLE_APIS_DRIVE_TIME_UTIL_H_ 36