修复时区不同导致的日期显示错误问题
This commit is contained in:
parent
fad9e5f5e3
commit
f62030696e
9
Gmeek.py
9
Gmeek.py
@ -87,6 +87,8 @@ class GMEEK():
|
|||||||
self.i18n=i18nRU
|
self.i18n=i18nRU
|
||||||
else:
|
else:
|
||||||
self.i18n=i18n
|
self.i18n=i18n
|
||||||
|
|
||||||
|
self.TZ=datetime.timezone(datetime.timedelta(hours=self.blogBase["UTC"]))
|
||||||
|
|
||||||
def get_repo(self,user:Github, repo:str):
|
def get_repo(self,user:Github, repo:str):
|
||||||
return user.get_repo(repo)
|
return user.get_repo(repo)
|
||||||
@ -307,7 +309,9 @@ class GMEEK():
|
|||||||
else:
|
else:
|
||||||
self.blogBase[listJsonName][postNum]["script"]=self.blogBase["script"]
|
self.blogBase[listJsonName][postNum]["script"]=self.blogBase["script"]
|
||||||
|
|
||||||
|
|
||||||
thisTime=datetime.datetime.fromtimestamp(self.blogBase[listJsonName][postNum]["createdAt"])
|
thisTime=datetime.datetime.fromtimestamp(self.blogBase[listJsonName][postNum]["createdAt"])
|
||||||
|
thisTime=thisTime.astimezone(self.TZ)
|
||||||
thisYear=thisTime.year
|
thisYear=thisTime.year
|
||||||
self.blogBase[listJsonName][postNum]["createdDate"]=thisTime.strftime("%Y-%m-%d")
|
self.blogBase[listJsonName][postNum]["createdDate"]=thisTime.strftime("%Y-%m-%d")
|
||||||
self.blogBase[listJsonName][postNum]["dateLabelColor"]=self.blogBase["yearColorList"][int(thisYear)%len(self.blogBase["yearColorList"])]
|
self.blogBase[listJsonName][postNum]["dateLabelColor"]=self.blogBase["yearColorList"][int(thisYear)%len(self.blogBase["yearColorList"])]
|
||||||
@ -407,12 +411,11 @@ docListFile.close()
|
|||||||
if os.environ.get('GITHUB_EVENT_NAME')!='schedule':
|
if os.environ.get('GITHUB_EVENT_NAME')!='schedule':
|
||||||
print("====== update readme file ======")
|
print("====== update readme file ======")
|
||||||
workspace_path = os.environ.get('GITHUB_WORKSPACE')
|
workspace_path = os.environ.get('GITHUB_WORKSPACE')
|
||||||
now = datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=blog.blogBase["UTC"])))
|
|
||||||
readme="# %s :link: %s \r\n" % (blog.blogBase["title"],blog.blogBase["homeUrl"])
|
readme="# %s :link: %s \r\n" % (blog.blogBase["title"],blog.blogBase["homeUrl"])
|
||||||
readme=readme+"### :page_facing_up: [%d](%s/tag.html) \r\n" % (len(blog.blogBase["postListJson"]),(blog.blogBase["homeUrl"]+"/tag.html"))
|
readme=readme+"### :page_facing_up: [%d](%s/tag.html) \r\n" % (len(blog.blogBase["postListJson"]),blog.blogBase["homeUrl"])
|
||||||
readme=readme+"### :speech_balloon: %d \r\n" % commentNumSum
|
readme=readme+"### :speech_balloon: %d \r\n" % commentNumSum
|
||||||
readme=readme+"### :hibiscus: %d \r\n" % wordCount
|
readme=readme+"### :hibiscus: %d \r\n" % wordCount
|
||||||
readme=readme+"### :alarm_clock: %s \r\n" % now.strftime('%Y-%m-%d %H:%M:%S')
|
readme=readme+"### :alarm_clock: %s \r\n" % datetime.datetime.now(blog.TZ).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
readme=readme+"### Powered by :heart: [Gmeek](https://github.com/Meekdai/Gmeek)\r\n"
|
readme=readme+"### Powered by :heart: [Gmeek](https://github.com/Meekdai/Gmeek)\r\n"
|
||||||
readmeFile=open(workspace_path+"/README.md","w")
|
readmeFile=open(workspace_path+"/README.md","w")
|
||||||
readmeFile.write(readme)
|
readmeFile.write(readme)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user