mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
Update mw.py
This commit is contained in:
@@ -404,6 +404,16 @@ def formatDate(fmat="%Y-%m-%d %H:%M:%S", times=None, time_zone=None):
|
|||||||
if not times:
|
if not times:
|
||||||
times = int(time.time())
|
times = int(time.time())
|
||||||
|
|
||||||
|
if time_zone is None:
|
||||||
|
try:
|
||||||
|
import tzlocal
|
||||||
|
time_zone = str(tzlocal.get_localzone())
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
time_zone = time.tzname[0]
|
||||||
|
except:
|
||||||
|
time_zone = None
|
||||||
|
|
||||||
if time_zone:
|
if time_zone:
|
||||||
old_tz = os.environ.get('TZ')
|
old_tz = os.environ.get('TZ')
|
||||||
os.environ['TZ'] = time_zone
|
os.environ['TZ'] = time_zone
|
||||||
|
|||||||
Reference in New Issue
Block a user