パンくずリスト

Blogger:投稿時刻の9時間ずれの修正 (2024/04/01)

Bloggerの投稿時刻の9時間ずれの修正 (2024/04/01)

2024年3月31日から4月1日へ日付がかわってすぐに、新しい記事をBloggerへ投稿したところ、投稿日が2024年3月31日になっていました。
生成されたHTMLやxmlのコードを調べてみると、どうやらBloggerのGMT+09:00の処理が正しくされていないようです。

先輩がいないかな~と、Webで調べると、いらっしゃいました。感謝します。

ガジェおたさんのサイト「ガジェおた(本館) • ダーク表示がオススメ!」のページ「"JetTheme" yyyy/m/d 日付フォーマット 対応版リリース! • ガジェおた(本館)」

https://blog.gadgets-geek.net/2021/12/jettheme-japanese-date-format.html

転載

ガジェおたさんのサイトから、一部分、転載させていただきました。(変更したのでじいじばあば用のメモとして)
じいじばあばの目的は「投稿時刻の9時間ずれの修正」のみだったのですが、なななんと投稿時刻に加えて改訂時刻も表示できるようになりました。
ただし、svgアイコンを追加するのが面倒だったので、その部分は手抜きをさせてもらって、svgアイコンのところは「, 改定」に変更してしまいました。(^^;)

テンプレートの変更です。(もし、変更される場合は、自己責任でお願いします。)
テンプレートの中に、「data:post.date.iso8601」が、5か所あります。
これら5か所のうち、1~3か所目と、5か所目にあるコードを変更します。4か所目は変更しません。

1~3か所目

1~3か所目の3か所において、次の、変更前のコードを、変更後のコードに置換します。

変更前:
<small class='me-2'><svg aria-hidden='true' class='me-1 jt-icon'><use xlink:href='#i-clock'/></svg><span class='date-format' expr:data-date='data:post.date.iso8601'><b:eval expr='data:jwidget.allBylineItems.timestamp.label ? data:post.date format data:jwidget.allBylineItems.timestamp.label : data:post.date'/></span></small>

変更後:
<small class='me-2'><svg aria-hidden='true' class='me-1 jt-icon'><use xlink:href='#i-clock'/></svg>
  <span class='date-format' expr:data-date='data:post.date.iso8601'><data:post.date.year/>/<b:eval expr='data:post.date.month lt 10 ? &quot;0&quot; + data:post.date.month : data:post.date.month'/>/<b:eval expr='data:post.date.day lt 10 ? &quot;0&quot; + data:post.date.day : data:post.date.day'/>
  </span>
  <b:if cond='data:post.date != data:post.lastUpdated'>
  , 改訂
  <span class='date-format' expr:data-date='data:post.lastUpdated.iso8601'><data:post.lastUpdated.year/>/<b:eval expr='data:post.lastUpdated.month lt 10 ? &quot;0&quot; + data:post.lastUpdated.month : data:post.lastUpdated.month'/>/<b:eval expr='data:post.lastUpdated.day lt 10 ? &quot;0&quot; + data:post.lastUpdated.day : data:post.lastUpdated.day'/>
  </span>
  </b:if>
</small>

4か所目

4か所目においては、何も変更しません。

5か所目

5か所目においては、次の、変更前のコードを、変更後のコードに置換します。

変更前:
<div class='me-3'><svg aria-hidden='true' class='me-1 jt-icon'><use xlink:href='#i-clock'/></svg><span class='date-format' expr:data-date='data:post.date.iso8601'><b:eval expr='data:jwidget.allBylineItems.timestamp.label ? data:post.date format data:jwidget.allBylineItems.timestamp.label : data:post.date'/></span></div>

変更後:
<div class='me-3'><svg aria-hidden='true' class='me-1 jt-icon'><use xlink:href='#i-clock'/></svg>
  <span class='date-format' expr:data-date='data:post.date.iso8601'><data:post.date.year/>/<b:eval expr='data:post.date.month lt 10 ? &quot;0&quot; + data:post.date.month : data:post.date.month'/>/<b:eval expr='data:post.date.day lt 10 ? &quot;0&quot; + data:post.date.day : data:post.date.day'/>
  </span>
  <b:if cond='data:post.date != data:post.lastUpdated'>
  , 改訂
  <span class='date-format' expr:data-date='data:post.lastUpdated.iso8601'><data:post.lastUpdated.year/>/<b:eval expr='data:post.lastUpdated.month lt 10 ? &quot;0&quot; + data:post.lastUpdated.month : data:post.lastUpdated.month'/>/<b:eval expr='data:post.lastUpdated.day lt 10 ? &quot;0&quot; + data:post.lastUpdated.day : data:post.lastUpdated.day'/>
  </span>
  </b:if>
</div>

前のページ 次のページ
No Comment
Add Comment
comment url