Skip to content

Commit df3a4af

Browse files
committed
日本時間にタイムゾーン変換し、タイムゾーンを明記 #53
1 parent 19dd0c6 commit df3a4af

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

boostjp/templates/content.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
{% if latest_commit_info %}
9393
<p class="text-right"><small>
9494
最終更新日時:
95-
<span itemprop="datePublished" content="{{ latest_commit_info['last_updated'].strftime('%Y-%m-%dT%H:%M:%S') }}">
96-
{{ latest_commit_info['last_updated'].strftime('%Y年%m月%d日 %H時%M分%S秒') }}
95+
<span itemprop="datePublished" content="{{ latest_commit_info['last_updated'].strftime('%Y-%m-%dT%H:%M:%S%z') }}">
96+
{{ latest_commit_info['last_updated'].strftime('%Y年%m月%d日 %H時%M分%S秒') }} (JST)
9797
</span>
9898
<br/>
9999
<span itemprop="author" itemscope itemtype="http://schema.org/Person">

cpprefjp/templates/content.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
{% block latest_commit_info %}
102102
{% if latest_commit_info %}
103103
<p class="text-right"><small>
104-
最終更新日時(UTC):
105-
<span itemprop="datePublished" content="{{ latest_commit_info['last_updated'].strftime('%Y-%m-%dT%H:%M:%S') }}">
106-
{{ latest_commit_info['last_updated'].strftime('%Y年%m月%d日 %H時%M分%S秒') }}
104+
最終更新日時:
105+
<span itemprop="datePublished" content="{{ latest_commit_info['last_updated'].strftime('%Y-%m-%dT%H:%M:%S%z') }}">
106+
{{ latest_commit_info['last_updated'].strftime('%Y年%m月%d日 %H時%M分%S秒') }} (JST)
107107
</span>
108108
<br/>
109109
<span itemprop="author" itemscope itemtype="http://schema.org/Person">

run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
from datetime import datetime
4+
from datetime import datetime, timedelta, timezone
55
import glob
66
import importlib
77
import json
@@ -469,13 +469,17 @@ def flush(self):
469469
f.write(json.dumps(self._cache))
470470

471471

472+
_JST = timezone(timedelta(hours=9), 'JST')
473+
474+
472475
def get_latest_commit_info(path):
473476
commit_log = subprocess.check_output(['git', 'log', '-1', '--date=iso', '--pretty=format:%at %an', path + '.md'], cwd=settings.INPUT_DIR, text=True, errors='ignore')
474477
if not commit_log:
475478
return None
476479
timestamp, author = commit_log.split(' ', 1)
477480
return {
478-
'last_updated': datetime.fromtimestamp(int(timestamp)),
481+
# git の %at は Unix 時刻 (UTC の瞬間) なので JST に変換して返す。
482+
'last_updated': datetime.fromtimestamp(int(timestamp), _JST),
479483
'last_author': author,
480484
}
481485

0 commit comments

Comments
 (0)