MCPcopy
hub / github.com/Delgan/loguru / aware_now

Function aware_now

loguru/_datetime.py:143–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

141
142
143def aware_now():
144 now = datetime_.now()
145 timestamp = now.timestamp()
146 local = localtime(timestamp)
147
148 try:
149 seconds = local.tm_gmtoff
150 zone = local.tm_zone
151 except AttributeError:
152 # Workaround for Python 3.5.
153 utc_naive = datetime_.fromtimestamp(timestamp, tz=timezone.utc).replace(tzinfo=None)
154 offset = datetime_.fromtimestamp(timestamp) - utc_naive
155 seconds = offset.total_seconds()
156 zone = strftime("%Z")
157
158 tzinfo = timezone(timedelta(seconds=seconds), zone)
159
160 return datetime.combine(now.date(), now.time().replace(tzinfo=tzinfo))

Callers 3

_logger.pyFile · 0.85
_logMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…