电日(E-Day)转换器

刷新

电日 > 日期

电日:
in

日期 > 电日

日期: - - : : :
表示代码

In Python:

import time, datetime

def e2d(eday):
    return datetime.datetime.utcfromtimestamp(eday*86400)

def d2e(date):
    return time.mktime(date.utctimetuple())/86400

A) Variant (Python >=3.9)

import datetime as dt
import zoneinfo as zf

# date -> eday
dt.datetime(YYYY, DD, MM, HH, MM, tzinfo=zf.ZoneInfo("SOURCE_ZONE")).astimezone(zf.ZoneInfo("UTC")).timestamp()/86400

# eday -> date
dt.datetime.fromtimestamp(YOUR_EDAY*86400).astimezone(zf.ZoneInfo("TARGET_ZONE"))

B) Variant

import datetime as dt
import pytz as tz

# date -> eday
tz.timezone("SOURCE_ZONE").localize(dt.datetime(YYYY, MM, DD, HH, MM), is_dst=None).astimezone(tz.utc).timestamp()/86400

# eday -> date
dt.datetime.fromtimestamp(YOUR_EDAY*86400).astimezone(tz.timezone("TARGET_ZONE"))