Skip to content

Commit

Permalink
fix: various scenarios of date boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Nov 13, 2024
1 parent 7f22efd commit 659fa61
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/auto-release/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function getReleaseData() {
let START_DATE = '';
let END_DATE = '';

const today = new Date();
const today = new Date('2024-06-01');

// 获取昨天的日期并且只取年月日格式化成'yyyy-mm-dd'
const someDaysAgo = new Date(today);
Expand All @@ -62,20 +62,19 @@ export function getReleaseData() {
console.log(`今天是:${today},开始日期:${START_DATE},结束日期:${END_DATE}`);

// release tag & 标题
let monthShort = today.toLocaleString('en-US', { month: 'short' });

const tagYear = today.getFullYear();
let tagMonth = today.getMonth() + 1;
let tagDay = today.getDate();
console.log('today', tagDay);

const tagYear = (today.getMonth() === 0 && today.getDate() === 1) ? today.getFullYear() - 1 : today.getFullYear();
const tagMonth = (today.getMonth() === 0 && tagDay === 1) ? 12 : today.getMonth() + (tagDay === 1 ? 0 : 1);

const monthShort = new Date(tagYear, tagMonth - 1).toLocaleString('en-US', { month: 'short' });

let times = '1st';

console.log('today', today.getDate());
switch (today.getDate()) {
switch (tagDay) {
case 1:
tagDay = 28;
tagMonth = today.getMonth();
monthShort = new Date(today.getFullYear(), today.getMonth() - 1).toLocaleString('en-US', { month: 'short' });
times = '4th';
break;
case 8:
Expand Down

0 comments on commit 659fa61

Please sign in to comment.