Пример #1
0
 def __init__(self, year, month, day, d=None):
     if d is None:
         d = JS("""new Date(@{{year}}, @{{month}} - 1, @{{day}}, 0, 0, 0, 0)""")
     self._d = d
     self.year = d.getFullYear()
     self.month = d.getMonth() + 1.0
     self.day = d.getDate()
Пример #2
0
 def __init__(self, year, month, day, d=None):
     if d is None:
         d = JS(
             """new Date(@{{year}}, @{{month}} - 1, @{{day}}, 0, 0, 0, 0)"""
         )
     self._d = d
     self.year = d.getFullYear()
     self.month = d.getMonth() + 1.0
     self.day = d.getDate()
Пример #3
0
def localtime(t=None):
    if t == None:
        t = time()
    date = JS("new Date(t*1000)")
    tm = struct_time()
    tm.tm_year = date.getFullYear()
    tm.tm_mon = date.getMonth() + 1
    tm.tm_mday = date.getDate()
    tm.tm_hour = date.getHours()
    tm.tm_min = date.getMinutes()
    tm.tm_sec = date.getSeconds()
    tm.tm_wday = (date.getDay() + 6) % 7
    startOfYear = int((JS("new Date(tm.tm_year,0,1)").getTime()) / 1000)
    tm.tm_yday = 1 + int((t - startOfYear) / 86400)
    tm.tm_isdst = date.getTimezoneOffset()
    return tm
Пример #4
0
def localtime(t=None):
    if t == None:
        t = time()
    date = JS("new Date(t*1000)")
    tm = struct_time()
    tm.tm_year = date.getFullYear()
    tm.tm_mon = date.getMonth() + 1
    tm.tm_mday = date.getDate()
    tm.tm_hour = date.getHours()
    tm.tm_min = date.getMinutes()
    tm.tm_sec = date.getSeconds()
    tm.tm_wday = (date.getDay() + 6) % 7
    startOfYear = int((JS("new Date(tm.tm_year,0,1)").getTime()) / 1000)
    tm.tm_yday = 1 + int((t - startOfYear) / 86400)
    tm.tm_isdst = date.getTimezoneOffset()
    return tm
Пример #5
0
def localtime(t=None):
    if t == None:
        t = time()
    date = JS("new Date(@{{t}}*1000)")
    dateOffset = date.getTimezoneOffset()
    tm = struct_time()
    tm_year = tm.tm_year = int(date.getFullYear())
    tm_mon = tm.tm_mon = int(date.getMonth()) + 1
    tm_mday = tm.tm_mday = int(date.getDate())
    tm.tm_hour = int(date.getHours())
    tm.tm_min = int(date.getMinutes())
    tm.tm_sec = int(date.getSeconds())
    tm.tm_wday = (int(date.getDay()) + 6) % 7
    tm.tm_isdst = 0 if timezone == 60 * date.getTimezoneOffset() else 1
    startOfYear = JS("new Date(@{{tm_year}},0,1)")  # local time
    startOfYearOffset = startOfYear.getTimezoneOffset()
    startOfDay = JS("new Date(@{{tm_year}},@{{tm_mon}}-1,@{{tm_mday}})")
    dt = float(startOfDay.getTime() - startOfYear.getTime()) / 1000
    dt = dt + 60 * (startOfYearOffset - dateOffset)
    tm.tm_yday = 1 + int(dt / 86400.0)
    return tm
Пример #6
0
def localtime(t=None):
    if t is None:
        t = time()
    date = JS("new Date(@{{t}}*1000)")
    dateOffset = date.getTimezoneOffset()
    tm = struct_time()
    tm_year = tm.tm_year = int(date.getFullYear())
    tm_mon = tm.tm_mon = int(date.getMonth()) + 1
    tm_mday = tm.tm_mday = int(date.getDate())
    tm.tm_hour = int(date.getHours())
    tm.tm_min = int(date.getMinutes())
    tm.tm_sec = int(date.getSeconds())
    tm.tm_wday = (int(date.getDay()) + 6) % 7
    tm.tm_isdst = 0 if timezone == 60*date.getTimezoneOffset() else 1
    startOfYear = JS("new Date(@{{tm_year}},0,1)") # local time
    startOfYearOffset = startOfYear.getTimezoneOffset()
    startOfDay = JS("new Date(@{{tm_year}},@{{tm_mon}}-1,@{{tm_mday}})")
    dt = float(startOfDay.getTime() - startOfYear.getTime())/1000
    dt = dt + 60 * (startOfYearOffset - dateOffset)
    tm.tm_yday = 1 + int(dt/86400.0)
    return tm