alter rewind nav to default to monthly rewind

This commit is contained in:
Gabe Farrell 2026-01-12 23:00:20 -05:00
parent a0b32f756e
commit 9678117c05
2 changed files with 10 additions and 7 deletions

View file

@ -16,12 +16,15 @@ const timeframeToInterval = (timeframe: Timeframe): string => {
};
const getRewindYear = (): number => {
return new Date().getFullYear() - 1;
};
const getRewindParams = (): string => {
const today = new Date();
if (today.getMonth() > 10 && today.getDate() >= 30) {
// if we are in december 30/31, just serve current year
return today.getFullYear();
if (today.getMonth() == 0) {
return `year=${today.getFullYear() - 1}`;
} else {
return today.getFullYear() - 1;
return `month=${today.getMonth()}`;
}
};
@ -114,5 +117,5 @@ const timeListenedString = (seconds: number) => {
return `${minutes} minutes listened`;
};
export { hexToHSL, timeListenedString, getRewindYear };
export { hexToHSL, timeListenedString, getRewindYear, getRewindParams };
export type { hsl };