From 6b42009043778a211c3babe66fc4dde8f89d8e8d Mon Sep 17 00:00:00 2001 From: isboyjc <214930661@qq.com> Date: Sun, 4 Aug 2024 20:03:56 +0800 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=90=9B:=20update=20rss=20pubdate=20for?= =?UTF-8?q?=20RFC=20822?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/run.yml | 18 +++++++++--------- .../.vitepress/theme/components/CustomHome.vue | 5 +++-- package.json | 1 + pnpm-lock.yaml | 10 ++++++++++ script/save.js | 3 ++- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index cb2c7abccdca..a066691b3100 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -1,14 +1,14 @@ name: Fetch GitHub Trending on: - # push: - # branches: - # - main - schedule: - - cron: '0 1 * * *' # UTC 凌晨 1 点 - - cron: '0 7 * * *' # UTC 早 7 点 - - cron: '0 13 * * *' # UTC 中午 1 点 - - cron: '0 19 * * *' # UTC 下午 7 点 + push: + branches: + - main + # schedule: + # - cron: '0 1 * * *' # UTC 凌晨 1 点 + # - cron: '0 7 * * *' # UTC 早 7 点 + # - cron: '0 13 * * *' # UTC 中午 1 点 + # - cron: '0 19 * * *' # UTC 下午 7 点 jobs: build: @@ -39,7 +39,7 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . - COMMIT_TIME=$(date +'%Y-%m-%d %H:%M:%S') + COMMIT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ) git commit -m "publish🚀: Fetch GitHub Trending at $COMMIT_TIME" git push env: diff --git a/docs/.vitepress/theme/components/CustomHome.vue b/docs/.vitepress/theme/components/CustomHome.vue index 88ea2e8bee17..e529fa1b46be 100644 --- a/docs/.vitepress/theme/components/CustomHome.vue +++ b/docs/.vitepress/theme/components/CustomHome.vue @@ -3,6 +3,7 @@ import { ref, computed, watch } from 'vue' import { useData } from 'vitepress' import { useClipboard } from '@vueuse/core' import moment from 'moment'; +import 'moment-timezone' import 'moment-duration-format'; import {t, routerPath} from '../locale' @@ -93,12 +94,12 @@ const pubDateFormat = computed(() => { if(!pubDate.value) return '' moment.locale(lang.value) - const time = moment.utc(pubDate.value, 'MMMM Do YYYY, h:mm:ss a'); + const time = moment(pubDate.value).tz('GMT').format('ddd, DD MMM YYYY HH:mm:ss [GMT]'); if (!time.isValid()) { throw new Error('Invalid time format'); } - const now = moment(); + const now = moment().tz('GMT').format('ddd, DD MMM YYYY HH:mm:ss [GMT]'); const duration = moment.duration(now.diff(time)); const seconds = Math.floor(duration.asSeconds()); diff --git a/package.json b/package.json index be0838eed1b2..8d6fd688c48a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "highlight.js": "^11.10.0", "moment": "^2.30.1", "moment-duration-format": "^2.3.2", + "moment-timezone": "^0.5.45", "vue": "^3.4.35", "xml2js": "^0.6.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ada060f6b9e8..ae0775cd8159 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: moment-duration-format: specifier: ^2.3.2 version: 2.3.2 + moment-timezone: + specifier: ^0.5.45 + version: 0.5.45 vue: specifier: ^3.4.35 version: 3.4.35 @@ -1494,6 +1497,9 @@ packages: moment-duration-format@2.3.2: resolution: {integrity: sha512-cBMXjSW+fjOb4tyaVHuaVE/A5TqkukDWiOfxxAjY+PEqmmBQlLwn+8OzwPiG3brouXKY5Un4pBjAeB6UToXHaQ==} + moment-timezone@0.5.45: + resolution: {integrity: sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==} + moment@2.30.1: resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} @@ -3515,6 +3521,10 @@ snapshots: moment-duration-format@2.3.2: {} + moment-timezone@0.5.45: + dependencies: + moment: 2.30.1 + moment@2.30.1: {} mri@1.2.0: diff --git a/script/save.js b/script/save.js index 6e81271a8585..8add137d4816 100644 --- a/script/save.js +++ b/script/save.js @@ -1,10 +1,11 @@ const moment = require('moment'); +require('moment-timezone') const path = require('path'); const { writeFileSync, readFileSync, mkdirSync } = require('fs'); const { Builder } = require('xml2js'); const { DATA_BASE_URL, TEMPLATE_BASE_URL } = require('./base') -const dateTime = moment().format('MMMM Do YYYY, h:mm:ss a'); +const dateTime = moment().tz('GMT').format('ddd, DD MMM YYYY HH:mm:ss [GMT]'); async function save (data, since = 'daily', language = 'all') { const filePath = DATA_BASE_URL + since