MCPcopy Index your code
hub / github.com/python/cpython / time2isoz

Function time2isoz

Lib/http/cookiejar.py:94–111  ·  view source on GitHub ↗

Return a string representing time in seconds since epoch, t. If the function is called without an argument, it will use the current time. The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ", representing Universal Time (UTC, aka GMT). An example of this format is:

(t=None)

Source from the content-addressed store, hash-verified

92MONTHS_LOWER = [month.lower() for month in MONTHS]
93
94def time2isoz(t=None):
95 """Return a string representing time in seconds since epoch, t.
96
97 If the function is called without an argument, it will use the current
98 time.
99
100 The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
101 representing Universal Time (UTC, aka GMT). An example of this format is:
102
103 1994-11-24 08:49:37Z
104
105 """
106 if t is None:
107 dt = datetime.datetime.now(tz=datetime.UTC)
108 else:
109 dt = datetime.datetime.fromtimestamp(t, tz=datetime.UTC)
110 return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
111 dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
112
113def time2netscape(t=None):
114 """Return a string representing time in seconds since epoch, t.

Callers 3

test_time2isozMethod · 0.90
lwp_cookie_strFunction · 0.85

Calls 2

nowMethod · 0.80
fromtimestampMethod · 0.45

Tested by 2

test_time2isozMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…