fix: the invalid time zone calculation for feature posts.

This commit is contained in:
Yufan Sheng 2024-11-07 20:39:36 +08:00
parent 60f95349d8
commit 149e331380
Signed by: syhily
GPG Key ID: 9D18A22A7DCD5A9B

View File

@ -2,6 +2,7 @@
import FeaturePost from '@/components/page/post/FeaturePost.astro'; import FeaturePost from '@/components/page/post/FeaturePost.astro';
import type { Post } from '@/helpers/schema'; import type { Post } from '@/helpers/schema';
import options from '@/options'; import options from '@/options';
import { DateTime } from 'luxon';
interface Props { interface Props {
posts: Post[]; posts: Post[];
@ -16,8 +17,8 @@ const historicalPosts = (): Post[] => {
return []; return [];
} }
const now = new Date(); const now = DateTime.now().setZone(options.settings.timeZone);
const radical = now.getMonth() + now.getDate(); const radical = now.month + now.day;
return [posts[offset + radical - 1], posts[offset + radical + 43 - 1], posts[offset + radical + 43 * 2 - 1]]; return [posts[offset + radical - 1], posts[offset + radical + 43 - 1], posts[offset + radical + 43 * 2 - 1]];
}; };