mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Move from deprecated moment#zone to moment#utcOffset (#12207)
* Issue 10209 - Remove read usages of zone * Issue 10209 - Add coverage on daysSince and startOfDay cron utility functions * Issue 10209 - Add unit test for daysUserHasMissed method * Issue 10209 - Remove usages of deprecated `moment.js#zone` method. * Issue 10209 - Add helper function to centralise logic Also simplify timezoneOffsetToUtc function in site.vue * Issue 10209 - Also add getUtcOffset as method on user Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
import i18n from '../i18n';
|
||||
import updateStats from '../fns/updateStats';
|
||||
import crit from '../fns/crit';
|
||||
import getUtcOffset from '../fns/getUtcOffset';
|
||||
|
||||
import statsComputed from '../libs/statsComputed';
|
||||
import { checkOnboardingStatus } from '../libs/onboarding';
|
||||
|
||||
@@ -194,14 +196,14 @@ function _lastHistoryEntryWasToday (lastHistoryEntry, user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { timezoneOffset } = user.preferences;
|
||||
const timezoneUtcOffset = getUtcOffset(user);
|
||||
const { dayStart } = user.preferences;
|
||||
|
||||
// Adjust the last entry date according to the user's timezone and CDS
|
||||
const dateWithTimeZone = moment(lastHistoryEntry.date).zone(timezoneOffset);
|
||||
const dateWithTimeZone = moment(lastHistoryEntry.date).utcOffset(timezoneUtcOffset);
|
||||
if (dateWithTimeZone.hour() < dayStart) dateWithTimeZone.subtract(1, 'day');
|
||||
|
||||
return moment().zone(timezoneOffset).isSame(dateWithTimeZone, 'day');
|
||||
return moment().utcOffset(timezoneUtcOffset).isSame(dateWithTimeZone, 'day');
|
||||
}
|
||||
|
||||
function _updateLastHistoryEntry (lastHistoryEntry, task, direction, times) {
|
||||
|
||||
Reference in New Issue
Block a user