mirror of https://github.com/go-gitea/gitea.git
Compare commits
3 Commits
e71a26a565
...
a388167c3d
Author | SHA1 | Date |
---|---|---|
Kemal Zebari | a388167c3d | |
Kemal Zebari | 4c6b196902 | |
Sam Fisher | 44ad644df8 |
|
@ -4,8 +4,8 @@ import {getCurrentLocale} from '../utils.js';
|
|||
// Returns an array of millisecond-timestamps of start-of-week days (Sundays)
|
||||
export function startDaysBetween(startDate, endDate) {
|
||||
// Ensure the start date is a Sunday
|
||||
while (startDate.getDay() !== 0) {
|
||||
startDate.setDate(startDate.getDate() + 1);
|
||||
while (startDate.getUTCDay() !== 0) {
|
||||
startDate.setUTCDate(startDate.getUTCDate() + 1);
|
||||
}
|
||||
|
||||
const start = dayjs(startDate);
|
||||
|
@ -29,10 +29,10 @@ export function firstStartDateAfterDate(inputDate) {
|
|||
if (!(inputDate instanceof Date)) {
|
||||
throw new Error('Invalid date');
|
||||
}
|
||||
const dayOfWeek = inputDate.getDay();
|
||||
const dayOfWeek = inputDate.getUTCDay();
|
||||
const daysUntilSunday = 7 - dayOfWeek;
|
||||
const resultDate = new Date(inputDate.getTime());
|
||||
resultDate.setDate(resultDate.getDate() + daysUntilSunday);
|
||||
resultDate.setUTCDate(resultDate.getUTCDate() + daysUntilSunday);
|
||||
return resultDate.valueOf();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue