Skip to content

Commit

Permalink
chore: improve date usage
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Jan 10, 2025
1 parent dc2b414 commit fc2a262
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/backend/server/src/__tests__/team.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ test('should be able to send mails', async t => {
}
});

test.only('should be able to emit events', async t => {
test('should be able to emit events', async t => {
const { app, event } = t.context;

{
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/server/src/base/mailer/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class MailService {
};

if (deletionDate) {
if (deletionDate > new Date()) {
if (deletionDate.getTime() > Date.now()) {
// in 24 hours
if (deletionDate.getTime() - Date.now() < 24 * 60 * 60 * 1000) {
baseContent.subject = `[Action Required] Final warning: Your ${workspaceName} data will be deleted in 24 hours`;
Expand All @@ -432,7 +432,7 @@ export class MailService {
Thank you for your support of AFFiNE. We hope to see you again in the future.`;
baseContent.button = undefined;
}
} else if (expirationDate < new Date()) {
} else if (expirationDate.getTime() < Date.now()) {
baseContent.subject = `Your ${workspaceName} team workspace has expired`;
baseContent.title = 'Team workspace expired';
baseContent.content = `Your ${workspaceName} team workspace expired on ${expirationDate}. Your workspace can't sync or collaborate with team members. Please renew your subscription to restore all team features.`;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/server/src/plugins/payment/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class SubscriptionCronJobs {
private readonly event: EventEmitter
) {}

private getDateRange(after: number, base = new Date()) {
private getDateRange(after: number, base: number | Date = Date.now()) {
const start = new Date(base);
start.setDate(start.getDate() + after);
start.setHours(0, 0, 0, 0);
Expand Down

0 comments on commit fc2a262

Please sign in to comment.