OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 | 5 |
6 """Provides functions for parsing and outputting Zulu time.""" | 6 """Provides functions for parsing and outputting Zulu time.""" |
7 | 7 |
8 import datetime | 8 import datetime |
9 import pytz | 9 import pytz |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 dt = dt.replace(tzinfo=pytz.UTC) | 45 dt = dt.replace(tzinfo=pytz.UTC) |
46 | 46 |
47 # Convert datetime into UTC. | 47 # Convert datetime into UTC. |
48 isodate = dt.astimezone(pytz.UTC).isoformat().split('+')[0] | 48 isodate = dt.astimezone(pytz.UTC).isoformat().split('+')[0] |
49 | 49 |
50 # Add fractional seconds if not present. | 50 # Add fractional seconds if not present. |
51 if '.' not in isodate: | 51 if '.' not in isodate: |
52 isodate += '.0' | 52 isodate += '.0' |
53 | 53 |
54 return isodate + 'Z' | 54 return isodate + 'Z' |
OLD | NEW |