本文整理汇总了Python中__pyjamas__.JS.getUTCHours方法的典型用法代码示例。如果您正苦于以下问题:Python JS.getUTCHours方法的具体用法?Python JS.getUTCHours怎么用?Python JS.getUTCHours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类__pyjamas__.JS
的用法示例。
在下文中一共展示了JS.getUTCHours方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gmtime
# 需要导入模块: from __pyjamas__ import JS [as 别名]
# 或者: from __pyjamas__.JS import getUTCHours [as 别名]
def gmtime(t=None):
if t == None:
t = time()
date = JS("new Date(t*1000)")
tm = struct_time()
tm.tm_year = date.getUTCFullYear()
tm.tm_mon = date.getUTCMonth() + 1
tm.tm_mday = date.getUTCDate()
tm.tm_hour = date.getUTCHours()
tm.tm_min = date.getUTCMinutes()
tm.tm_sec = date.getUTCSeconds()
tm.tm_wday = (date.getUTCDay() + 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 = 0
return tm
示例2: gmtime
# 需要导入模块: from __pyjamas__ import JS [as 别名]
# 或者: from __pyjamas__.JS import getUTCHours [as 别名]
def gmtime(t=None):
if t is None:
t = time()
date = JS("new Date(@{{t}}*1000)")
tm = struct_time()
tm_year = tm.tm_year = int(date.getUTCFullYear())
tm.tm_mon = int(date.getUTCMonth()) + 1
tm.tm_mday = int(date.getUTCDate())
tm.tm_hour = int(date.getUTCHours())
tm.tm_min = int(date.getUTCMinutes())
tm.tm_sec = int(date.getUTCSeconds())
tm.tm_wday = (int(date.getUTCDay()) + 6) % 7
tm.tm_isdst = 0
startOfYear = JS("new Date('Jan 1 '+ @{{tm_year}} +' GMT+0000')")
tm.tm_yday = 1 + int((t - startOfYear.getTime()/1000)/86400)
return tm