| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 #include "net/der/encode_values.h" | 6 #include "net/der/encode_values.h" |
| 7 | 7 |
| 8 namespace net { | 8 namespace net { |
| 9 | 9 |
| 10 namespace der { | 10 namespace der { |
| 11 | 11 |
| 12 bool EncodeTimeAsGeneralizedTime(const base::Time& time, | 12 bool EncodeTimeAsGeneralizedTime(const base::Time& time, |
| 13 der::GeneralizedTime* generalized_time) { | 13 der::GeneralizedTime* generalized_time) { |
| 14 base::Time::Exploded exploded; | 14 base::Time::Exploded exploded; |
| 15 time.UTCExplode(&exploded); | 15 time.UTCExplode(&exploded); |
| 16 if (!exploded.HasValidValues()) | 16 if (!exploded.HasValidValues()) |
| 17 return false; | 17 return false; |
| 18 | 18 |
| 19 generalized_time->year = exploded.year; | 19 generalized_time->year = exploded.year; |
| 20 generalized_time->month = exploded.month; | 20 generalized_time->month = exploded.month; |
| 21 generalized_time->day = exploded.day_of_month; | 21 generalized_time->day = exploded.day_of_month; |
| 22 generalized_time->hours = exploded.hour; | 22 generalized_time->hours = exploded.hour; |
| 23 generalized_time->minutes = exploded.minute; | 23 generalized_time->minutes = exploded.minute; |
| 24 generalized_time->seconds = exploded.second; | 24 generalized_time->seconds = exploded.second; |
| 25 return true; | 25 return true; |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace der | 28 } // namespace der |
| 29 | 29 |
| 30 } // namespace net | 30 } // namespace net |
| OLD | NEW |