Skip to content

Commit

Permalink
Merge pull request #1427 from appwrite/feat-daily-policy-localtime
Browse files Browse the repository at this point in the history
Set default pro plan policy schedule to midnight local time
  • Loading branch information
christyjacob4 authored Oct 18, 2024
2 parents 801274c + aa0a01b commit b3ac06b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib/helpers/backups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export const cronExpression = (policy: UserBackupPolicy) => {
let cronExpression = '';

if (policy.default) {
// default should use utc.
cronExpression = policy.schedule;
now.setHours(0, 0, 0);
const utcHour = now.getUTCHours();

cronExpression = policy.schedule.replace('{time}', `0 ${utcHour}`);
} else {
const [localHour, localMinute] = policy.selectedTime.split(':');
now.setHours(parseInt(localHour), parseInt(localMinute), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const presetPolicies = writable<UserBackupPolicy[]>([
retained: 7,
default: true,
checked: false,
schedule: '0 0 * * *',
schedule: '{time} * * *',
selectedTime: '00:00',
plainTextFrequency: 'daily',
description: 'Runs every day and is retained for 7 days'
Expand Down

0 comments on commit b3ac06b

Please sign in to comment.