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

Function time2netscape

Lib/http/cookiejar.py:113–130  ·  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 this: Wed, DD-Mon-YYYY HH:MM:SS GMT

(t=None)

Source from the content-addressed store, hash-verified

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.
115
116 If the function is called without an argument, it will use the current
117 time.
118
119 The format of the returned string is like this:
120
121 Wed, DD-Mon-YYYY HH:MM:SS GMT
122
123 """
124 if t is None:
125 dt = datetime.datetime.now(tz=datetime.UTC)
126 else:
127 dt = datetime.datetime.fromtimestamp(t, tz=datetime.UTC)
128 return "%s, %02d-%s-%04d %02d:%02d:%02d GMT" % (
129 DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
130 dt.year, dt.hour, dt.minute, dt.second)
131
132
133UTC_ZONES = {"GMT": None, "UTC": None, "UT": None, "Z": None}

Callers 3

test_time2netscapeMethod · 0.90
test_expiresMethod · 0.90

Calls 3

nowMethod · 0.80
fromtimestampMethod · 0.45
weekdayMethod · 0.45

Tested by 3

test_time2netscapeMethod · 0.72
test_expiresMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…