/usr/lib/python2.7/dist-packages/cylc/strftime.py is in python-cylc 7.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #!/usr/bin/env python
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2017 NIWA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
def strftime(dt, template):
"""A replacement for datetime.strftime() which does not handle dates
earlier than 1900 (or beyond 2048?)."""
iso = dt.isoformat()
return isoformat_strftime(iso, template)
def isoformat_strftime(iso_string, template):
"""Re-template a datetime.datetime isoformat string."""
d, t = iso_string.split('T')
Y, m, d = d.split('-')
H, M, S = t.split(':')
t = template.replace('%Y', Y)
t = t.replace('%m', m)
t = t.replace('%d', d)
t = t.replace('%H', H)
t = t.replace('%M', M)
t = t.replace('%S', S[0:2])
return t
if __name__ == '__main__':
dt1 = datetime.datetime(1900, 1, 1)
dt2 = datetime.datetime(1600, 1, 1)
print strftime(dt1, "%Y-%m-%d %H:%M:%S")
print dt1.strftime("%Y-%m-%d %H:%M:%S")
print strftime(dt2, "%Y-%m-%d %H:%M:%S")
print dt2.strftime("%Y-%m-%d %H:%M:%S") # FAILS
|