Skip to content

Commit

Permalink
migrate consts/datetime.js to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Jan 1, 2025
1 parent 5525635 commit c4b74dc
Show file tree
Hide file tree
Showing 22 changed files with 629 additions and 661 deletions.
14 changes: 7 additions & 7 deletions src/components/desktop/DateRangeSelectionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { useTheme } from 'vuetify';
import { mapStores } from 'pinia';
import { useUserStore } from '@/stores/user.js';
import datetimeConstants from '@/consts/datetime.js';
import { DateRange } from '@/core/datetime.ts';
import { ThemeType } from '@/core/theme.ts';
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
import {
Expand Down Expand Up @@ -149,12 +149,12 @@ export default {
const presetRanges = [];
[
datetimeConstants.allDateRanges.Today,
datetimeConstants.allDateRanges.LastSevenDays,
datetimeConstants.allDateRanges.LastThirtyDays,
datetimeConstants.allDateRanges.ThisWeek,
datetimeConstants.allDateRanges.ThisMonth,
datetimeConstants.allDateRanges.ThisYear
DateRange.Today,
DateRange.LastSevenDays,
DateRange.LastThirtyDays,
DateRange.ThisWeek,
DateRange.ThisMonth,
DateRange.ThisYear
].forEach(dateRangeType => {
const dateRange = getDateRangeByDateType(dateRangeType.type, this.firstDayOfWeek);
Expand Down
6 changes: 3 additions & 3 deletions src/components/desktop/TrendsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { DateRangeScene } from '@/core/datetime.ts';
import { ThemeType } from '@/core/theme.ts';
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
import datetimeConstants from '@/consts/datetime.js';
import statisticsConstants from '@/consts/statistics.js';
import { ThemeType } from '@/core/theme.ts';
import {
isArray,
isNumber
Expand Down Expand Up @@ -376,7 +376,7 @@ export default {
}
}
const dateRangeType = getDateTypeByDateRange(minUnixTime, maxUnixTime, this.userStore.currentUserFirstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
const dateRangeType = getDateTypeByDateRange(minUnixTime, maxUnixTime, this.userStore.currentUserFirstDayOfWeek, DateRangeScene.Normal);
this.$emit('click', {
itemId: itemId,
Expand Down
14 changes: 7 additions & 7 deletions src/components/mobile/DateRangeSelectionSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import { mapStores } from 'pinia';
import { useUserStore } from '@/stores/user.js';
import datetimeConstants from '@/consts/datetime.js';
import { DateRange } from '@/core/datetime.ts';
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
import {
getCurrentUnixTime,
Expand Down Expand Up @@ -136,12 +136,12 @@ export default {
const presetRanges = [];
[
datetimeConstants.allDateRanges.Today,
datetimeConstants.allDateRanges.LastSevenDays,
datetimeConstants.allDateRanges.LastThirtyDays,
datetimeConstants.allDateRanges.ThisWeek,
datetimeConstants.allDateRanges.ThisMonth,
datetimeConstants.allDateRanges.ThisYear
DateRange.Today,
DateRange.LastSevenDays,
DateRange.LastThirtyDays,
DateRange.ThisWeek,
DateRange.ThisMonth,
DateRange.ThisYear
].forEach(dateRangeType => {
const dateRange = getDateRangeByDateType(dateRangeType.type, this.firstDayOfWeek);
Expand Down
22 changes: 7 additions & 15 deletions src/components/mobile/DateTimeSelectionSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import { mapStores } from 'pinia';
import { useUserStore } from '@/stores/user.js';
import datetimeConstants from '@/consts/datetime.js';
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
import {
getCurrentUnixTime,
Expand Down Expand Up @@ -202,19 +201,15 @@ export default {
return getTimeValues(datetime, this.is24Hour, this.isMeridiemIndicatorFirst);
},
getTimePickerColumns() {
const self = this;
const ret = [];
if (!self.is24Hour && this.isMeridiemIndicatorFirst) {
ret.push({
values: datetimeConstants.allMeridiemIndicatorsArray,
displayValues: self.$locale.getAllMeridiemIndicatorNames()
});
if (!this.is24Hour && this.isMeridiemIndicatorFirst) {
ret.push(this.$locale.getAllMeridiemIndicators());
}
// Hours
ret.push({
values: self.generateAllHours()
values: this.generateAllHours()
});
// Divider
ret.push({
Expand All @@ -223,7 +218,7 @@ export default {
});
// Minutes
ret.push({
values: self.generateAllMinutesOrSeconds()
values: this.generateAllMinutesOrSeconds()
});
// Divider
ret.push({
Expand All @@ -232,14 +227,11 @@ export default {
});
// Seconds
ret.push({
values: self.generateAllMinutesOrSeconds()
values: this.generateAllMinutesOrSeconds()
});
if (!self.is24Hour && !this.isMeridiemIndicatorFirst) {
ret.push({
values: datetimeConstants.allMeridiemIndicatorsArray,
displayValues: self.$locale.getAllMeridiemIndicatorNames()
});
if (!this.is24Hour && !this.isMeridiemIndicatorFirst) {
ret.push(this.$locale.getAllMeridiemIndicators());
}
return ret;
Expand Down
4 changes: 2 additions & 2 deletions src/components/mobile/TrendsBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { DateRangeScene } from '@/core/datetime.ts';
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
import datetimeConstants from '@/consts/datetime.js';
import statisticsConstants from '@/consts/statistics.js';
import { isNumber } from '@/lib/common.ts';
import {
Expand Down Expand Up @@ -303,7 +303,7 @@ export default {
}
}
const dateRangeType = getDateTypeByDateRange(minUnixTime, maxUnixTime, this.userStore.currentUserFirstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
const dateRangeType = getDateTypeByDateRange(minUnixTime, maxUnixTime, this.userStore.currentUserFirstDayOfWeek, DateRangeScene.Normal);
this.$emit('click', {
itemId: itemId,
Expand Down
Loading

0 comments on commit c4b74dc

Please sign in to comment.