Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: calculation should be UTC now instead of executor's now #397

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/contracts-sdk/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ export function convertRequestsPerDayToPerSecond(
// Calculates the expiration timestamp in UTC for a given number of days from now.
// The expiration time is set to midnight (00:00:00) UTC of the target day.
export function calculateUTCMidnightExpiration(daysFromNow: number): number {
// Create a Date object for the current time in UTC
const now = new Date();
const futureDate = new Date(
const utcNow = Date.UTC(
now.getUTCFullYear(),
now.getUTCMonth(),
now.getUTCDate() + daysFromNow
now.getUTCDate()
);

// Create a future Date object in UTC, adding the specified number of days
const futureDate = new Date(utcNow);
futureDate.setUTCDate(futureDate.getUTCDate() + daysFromNow);
futureDate.setUTCHours(0, 0, 0, 0); // Set to midnight UTC

return Math.floor(futureDate.getTime() / 1000);
}

Expand Down
Loading