mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
calendar display type supports Gregorian with Persian, date display type supports Persian calendar
This commit is contained in:
Generated
+15
@@ -20,6 +20,7 @@
|
|||||||
"framework7": "^8.3.4",
|
"framework7": "^8.3.4",
|
||||||
"framework7-icons": "^5.0.5",
|
"framework7-icons": "^5.0.5",
|
||||||
"framework7-vue": "^8.3.4",
|
"framework7-vue": "^8.3.4",
|
||||||
|
"jalaali-js": "^1.2.8",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"line-awesome": "^1.3.0",
|
"line-awesome": "^1.3.0",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
"@types/cbor-js": "^0.1.1",
|
"@types/cbor-js": "^0.1.1",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/git-rev-sync": "^2.0.2",
|
"@types/git-rev-sync": "^2.0.2",
|
||||||
|
"@types/jalaali-js": "^1.2.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^22.15.29",
|
"@types/node": "^22.15.29",
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
@@ -5154,6 +5156,13 @@
|
|||||||
"@types/istanbul-lib-report": "*"
|
"@types/istanbul-lib-report": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/jalaali-js": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/jalaali-js/-/jalaali-js-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-DRQKjbfFe0/v3siCou9eFzYjDxJItkJpxbU+/CSptvoRqq2/VmTA6y8QvqK/VELKW6xX3qb174nLZlrFV9OT3Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/jest": {
|
"node_modules/@types/jest": {
|
||||||
"version": "29.5.14",
|
"version": "29.5.14",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz",
|
||||||
@@ -9133,6 +9142,12 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/jalaali-js": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/jalaali-js/-/jalaali-js-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-Jl/EwY84JwjW2wsWqeU4pNd22VNQ7EkjI36bDuLw31wH98WQW4fPjD0+mG7cdCK+Y8D6s9R3zLiQ3LaKu6bD8A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/jest": {
|
"node_modules/jest": {
|
||||||
"version": "29.7.0",
|
"version": "29.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"framework7": "^8.3.4",
|
"framework7": "^8.3.4",
|
||||||
"framework7-icons": "^5.0.5",
|
"framework7-icons": "^5.0.5",
|
||||||
"framework7-vue": "^8.3.4",
|
"framework7-vue": "^8.3.4",
|
||||||
|
"jalaali-js": "^1.2.8",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"line-awesome": "^1.3.0",
|
"line-awesome": "^1.3.0",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
@@ -53,6 +54,7 @@
|
|||||||
"@types/cbor-js": "^0.1.1",
|
"@types/cbor-js": "^0.1.1",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/git-rev-sync": "^2.0.2",
|
"@types/git-rev-sync": "^2.0.2",
|
||||||
|
"@types/jalaali-js": "^1.2.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^22.15.29",
|
"@types/node": "^22.15.29",
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const (
|
|||||||
CALENDAR_DISPLAY_TYPE_GREGORAIN CalendarDisplayType = 1
|
CALENDAR_DISPLAY_TYPE_GREGORAIN CalendarDisplayType = 1
|
||||||
CALENDAR_DISPLAY_TYPE_BUDDHIST CalendarDisplayType = 2
|
CALENDAR_DISPLAY_TYPE_BUDDHIST CalendarDisplayType = 2
|
||||||
CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE CalendarDisplayType = 3
|
CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE CalendarDisplayType = 3
|
||||||
|
CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_PERSIAN CalendarDisplayType = 4
|
||||||
CALENDAR_DISPLAY_TYPE_INVALID CalendarDisplayType = 255
|
CALENDAR_DISPLAY_TYPE_INVALID CalendarDisplayType = 255
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ func (f CalendarDisplayType) String() string {
|
|||||||
return "Buddhist"
|
return "Buddhist"
|
||||||
case CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE:
|
case CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE:
|
||||||
return "Gregorian with Chinese"
|
return "Gregorian with Chinese"
|
||||||
|
case CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_PERSIAN:
|
||||||
|
return "Gregorian with Persian"
|
||||||
case CALENDAR_DISPLAY_TYPE_INVALID:
|
case CALENDAR_DISPLAY_TYPE_INVALID:
|
||||||
return "Invalid"
|
return "Invalid"
|
||||||
default:
|
default:
|
||||||
@@ -40,6 +43,7 @@ const (
|
|||||||
DATE_DISPLAY_TYPE_DEFAULT DateDisplayType = 0
|
DATE_DISPLAY_TYPE_DEFAULT DateDisplayType = 0
|
||||||
DATE_DISPLAY_TYPE_GREGORAIN DateDisplayType = 1
|
DATE_DISPLAY_TYPE_GREGORAIN DateDisplayType = 1
|
||||||
DATE_DISPLAY_TYPE_BUDDHIST DateDisplayType = 2
|
DATE_DISPLAY_TYPE_BUDDHIST DateDisplayType = 2
|
||||||
|
DATE_DISPLAY_TYPE_PERSIAN DateDisplayType = 3
|
||||||
DATE_DISPLAY_TYPE_INVALID DateDisplayType = 255
|
DATE_DISPLAY_TYPE_INVALID DateDisplayType = 255
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,6 +56,8 @@ func (f DateDisplayType) String() string {
|
|||||||
return "Gregorian"
|
return "Gregorian"
|
||||||
case DATE_DISPLAY_TYPE_BUDDHIST:
|
case DATE_DISPLAY_TYPE_BUDDHIST:
|
||||||
return "Buddhist"
|
return "Buddhist"
|
||||||
|
case DATE_DISPLAY_TYPE_PERSIAN:
|
||||||
|
return "Persian"
|
||||||
case DATE_DISPLAY_TYPE_INVALID:
|
case DATE_DISPLAY_TYPE_INVALID:
|
||||||
return "Invalid"
|
return "Invalid"
|
||||||
default:
|
default:
|
||||||
|
|||||||
+2
-2
@@ -199,8 +199,8 @@ type UserProfileUpdateRequest struct {
|
|||||||
DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"`
|
DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"`
|
||||||
FirstDayOfWeek *core.WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"`
|
FirstDayOfWeek *core.WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"`
|
||||||
FiscalYearStart *core.FiscalYearStart `json:"fiscalYearStart" binding:"omitempty,validFiscalYearStart"`
|
FiscalYearStart *core.FiscalYearStart `json:"fiscalYearStart" binding:"omitempty,validFiscalYearStart"`
|
||||||
CalendarDisplayType *core.CalendarDisplayType `json:"calendarDisplayType" binding:"omitempty,min=0,max=3"`
|
CalendarDisplayType *core.CalendarDisplayType `json:"calendarDisplayType" binding:"omitempty,min=0,max=4"`
|
||||||
DateDisplayType *core.DateDisplayType `json:"dateDisplayType" binding:"omitempty,min=0,max=2"`
|
DateDisplayType *core.DateDisplayType `json:"dateDisplayType" binding:"omitempty,min=0,max=3"`
|
||||||
LongDateFormat *core.LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"`
|
LongDateFormat *core.LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"`
|
||||||
ShortDateFormat *core.ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"`
|
ShortDateFormat *core.ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"`
|
||||||
LongTimeFormat *core.LongTimeFormat `json:"longTimeFormat" binding:"omitempty,min=0,max=3"`
|
LongTimeFormat *core.LongTimeFormat `json:"longTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||||
|
|||||||
@@ -293,11 +293,11 @@ func (s *UserService) UpdateUser(c core.Context, user *models.User, modifyUserLa
|
|||||||
updateCols = append(updateCols, "fiscal_year_start")
|
updateCols = append(updateCols, "fiscal_year_start")
|
||||||
}
|
}
|
||||||
|
|
||||||
if core.CALENDAR_DISPLAY_TYPE_DEFAULT <= user.CalendarDisplayType && user.CalendarDisplayType <= core.CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE {
|
if core.CALENDAR_DISPLAY_TYPE_DEFAULT <= user.CalendarDisplayType && user.CalendarDisplayType <= core.CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_PERSIAN {
|
||||||
updateCols = append(updateCols, "calendar_display_type")
|
updateCols = append(updateCols, "calendar_display_type")
|
||||||
}
|
}
|
||||||
|
|
||||||
if core.DATE_DISPLAY_TYPE_DEFAULT <= user.DateDisplayType && user.DateDisplayType <= core.DATE_DISPLAY_TYPE_BUDDHIST {
|
if core.DATE_DISPLAY_TYPE_DEFAULT <= user.DateDisplayType && user.DateDisplayType <= core.DATE_DISPLAY_TYPE_PERSIAN {
|
||||||
updateCols = append(updateCols, "date_display_type")
|
updateCols = append(updateCols, "date_display_type")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -3,7 +3,8 @@ import type { TypeAndName } from '@/core/base.ts';
|
|||||||
export enum CalendarType {
|
export enum CalendarType {
|
||||||
Gregorian = 0,
|
Gregorian = 0,
|
||||||
Buddhist = 1,
|
Buddhist = 1,
|
||||||
Chinese = 2
|
Chinese = 2,
|
||||||
|
Persian = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChineseCalendarLocaleData {
|
export interface ChineseCalendarLocaleData {
|
||||||
@@ -14,6 +15,11 @@ export interface ChineseCalendarLocaleData {
|
|||||||
readonly solarTermNames: string[];
|
readonly solarTermNames: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersianCalendarLocaleData {
|
||||||
|
readonly monthNames: string[];
|
||||||
|
readonly monthShortNames: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export class CalendarDisplayType implements TypeAndName {
|
export class CalendarDisplayType implements TypeAndName {
|
||||||
private static readonly allInstances: CalendarDisplayType[] = [];
|
private static readonly allInstances: CalendarDisplayType[] = [];
|
||||||
private static readonly allInstancesByType: Record<number, CalendarDisplayType> = {};
|
private static readonly allInstancesByType: Record<number, CalendarDisplayType> = {};
|
||||||
@@ -23,6 +29,7 @@ export class CalendarDisplayType implements TypeAndName {
|
|||||||
public static readonly Gregorian = new CalendarDisplayType(1, 'Gregorian', 'Gregorian', CalendarType.Gregorian);
|
public static readonly Gregorian = new CalendarDisplayType(1, 'Gregorian', 'Gregorian', CalendarType.Gregorian);
|
||||||
public static readonly Buddhist = new CalendarDisplayType(2, 'Buddhist', 'Buddhist', CalendarType.Buddhist);
|
public static readonly Buddhist = new CalendarDisplayType(2, 'Buddhist', 'Buddhist', CalendarType.Buddhist);
|
||||||
public static readonly GregorianWithChinese = new CalendarDisplayType(3, 'GregorianWithChinese', 'Gregorian with Chinese', CalendarType.Gregorian, CalendarType.Chinese);
|
public static readonly GregorianWithChinese = new CalendarDisplayType(3, 'GregorianWithChinese', 'Gregorian with Chinese', CalendarType.Gregorian, CalendarType.Chinese);
|
||||||
|
public static readonly GregorianWithPersian = new CalendarDisplayType(4, 'GregorianWithPersian', 'Gregorian with Persian', CalendarType.Gregorian, CalendarType.Persian);
|
||||||
|
|
||||||
public static readonly Default = CalendarDisplayType.Gregorian;
|
public static readonly Default = CalendarDisplayType.Gregorian;
|
||||||
|
|
||||||
@@ -64,7 +71,8 @@ export class DateDisplayType implements TypeAndName {
|
|||||||
|
|
||||||
public static readonly LanguageDefaultType: number = 0;
|
public static readonly LanguageDefaultType: number = 0;
|
||||||
public static readonly Gregorian = new DateDisplayType(1, 'Gregorian', 'Gregorian', CalendarType.Gregorian);
|
public static readonly Gregorian = new DateDisplayType(1, 'Gregorian', 'Gregorian', CalendarType.Gregorian);
|
||||||
public static readonly Chinese = new DateDisplayType(2, 'Buddhist', 'Buddhist', CalendarType.Buddhist);
|
public static readonly Buddhist = new DateDisplayType(2, 'Buddhist', 'Buddhist', CalendarType.Buddhist);
|
||||||
|
public static readonly Persian = new DateDisplayType(3, 'Persian', 'Persian', CalendarType.Persian);
|
||||||
|
|
||||||
public static readonly Default = DateDisplayType.Gregorian;
|
public static readonly Default = DateDisplayType.Gregorian;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { TypeAndName, TypeAndDisplayName } from '@/core/base.ts';
|
import type { TypeAndName, TypeAndDisplayName } from '@/core/base.ts';
|
||||||
import type { CalendarType, ChineseCalendarLocaleData } from '@/core/calendar.ts';
|
import type { CalendarType, ChineseCalendarLocaleData, PersianCalendarLocaleData } from '@/core/calendar.ts';
|
||||||
import type { NumeralSystem } from '@/core/numeral.ts';
|
import type { NumeralSystem } from '@/core/numeral.ts';
|
||||||
|
|
||||||
export interface DateTime {
|
export interface DateTime {
|
||||||
@@ -16,6 +16,7 @@ export interface DateTime {
|
|||||||
getLocalizedCalendarMonthDisplayShortName(options: DateTimeFormatOptions): string;
|
getLocalizedCalendarMonthDisplayShortName(options: DateTimeFormatOptions): string;
|
||||||
getGregorianCalendarDay(): number;
|
getGregorianCalendarDay(): number;
|
||||||
getLocalizedCalendarDay(options: DateTimeFormatOptions): string;
|
getLocalizedCalendarDay(options: DateTimeFormatOptions): string;
|
||||||
|
isLocalizedCalendarFirstDayOfMonth(options: DateTimeFormatOptions): boolean;
|
||||||
getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay;
|
getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay;
|
||||||
getGregorianCalendarYearDashMonth(): TextualYearMonth;
|
getGregorianCalendarYearDashMonth(): TextualYearMonth;
|
||||||
getWeekDay(): WeekDay;
|
getWeekDay(): WeekDay;
|
||||||
@@ -37,6 +38,7 @@ export interface DateTimeFormatOptions {
|
|||||||
calendarType: CalendarType;
|
calendarType: CalendarType;
|
||||||
localeData: DateTimeLocaleData;
|
localeData: DateTimeLocaleData;
|
||||||
chineseCalendarLocaleData: ChineseCalendarLocaleData;
|
chineseCalendarLocaleData: ChineseCalendarLocaleData;
|
||||||
|
persianCalendarLocaleData: PersianCalendarLocaleData;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DateTimeLocaleData {
|
export interface DateTimeLocaleData {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { type unitOfTime } from 'moment/moment';
|
import { type unitOfTime } from 'moment/moment';
|
||||||
|
|
||||||
|
import jalaali, { type JalaaliDateObject } from 'jalaali-js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type ChineseCalendarLocaleData,
|
type ChineseCalendarLocaleData,
|
||||||
CalendarType
|
CalendarType
|
||||||
@@ -91,6 +93,7 @@ class MomentDateTime implements DateTime {
|
|||||||
|
|
||||||
private readonly instance: moment.Moment;
|
private readonly instance: moment.Moment;
|
||||||
private chineseDateInfo?: ChineseYearMonthDayInfo | undefined = undefined;
|
private chineseDateInfo?: ChineseYearMonthDayInfo | undefined = undefined;
|
||||||
|
private persianDateInfo?: JalaaliDateObject | undefined = undefined;
|
||||||
|
|
||||||
private constructor(instance: moment.Moment) {
|
private constructor(instance: moment.Moment) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
@@ -105,6 +108,8 @@ class MomentDateTime implements DateTime {
|
|||||||
return (this.instance.year() + 543).toString();
|
return (this.instance.year() + 543).toString();
|
||||||
} else if (options && options.calendarType === CalendarType.Chinese) {
|
} else if (options && options.calendarType === CalendarType.Chinese) {
|
||||||
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayYear ?? '';
|
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayYear ?? '';
|
||||||
|
} else if (options && options.calendarType === CalendarType.Persian) {
|
||||||
|
return this.getPersianDateInfo().jy.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.instance.year().toString();
|
return this.instance.year().toString();
|
||||||
@@ -148,6 +153,8 @@ class MomentDateTime implements DateTime {
|
|||||||
public getLocalizedCalendarMonth(options: DateTimeFormatOptions): string {
|
public getLocalizedCalendarMonth(options: DateTimeFormatOptions): string {
|
||||||
if (options && options.calendarType === CalendarType.Chinese) {
|
if (options && options.calendarType === CalendarType.Chinese) {
|
||||||
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayMonth ?? '';
|
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayMonth ?? '';
|
||||||
|
} else if (options && options.calendarType === CalendarType.Persian) {
|
||||||
|
return this.getPersianDateInfo().jm.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (this.instance.month() + 1).toString();
|
return (this.instance.month() + 1).toString();
|
||||||
@@ -160,6 +167,8 @@ class MomentDateTime implements DateTime {
|
|||||||
|
|
||||||
if (options && options.calendarType === CalendarType.Chinese) {
|
if (options && options.calendarType === CalendarType.Chinese) {
|
||||||
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayMonth ?? '';
|
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayMonth ?? '';
|
||||||
|
} else if (options && options.calendarType === CalendarType.Persian) {
|
||||||
|
return options.persianCalendarLocaleData.monthNames[this.getPersianDateInfo().jm - 1] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const names = options.localeData.months();
|
const names = options.localeData.months();
|
||||||
@@ -173,6 +182,8 @@ class MomentDateTime implements DateTime {
|
|||||||
|
|
||||||
if (options && options.calendarType === CalendarType.Chinese) {
|
if (options && options.calendarType === CalendarType.Chinese) {
|
||||||
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayMonth ?? '';
|
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayMonth ?? '';
|
||||||
|
} else if (options && options.calendarType === CalendarType.Persian) {
|
||||||
|
return options.persianCalendarLocaleData.monthShortNames[this.getPersianDateInfo().jm - 1] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const names = options.localeData.monthsShort();
|
const names = options.localeData.monthsShort();
|
||||||
@@ -186,11 +197,23 @@ class MomentDateTime implements DateTime {
|
|||||||
public getLocalizedCalendarDay(options: DateTimeFormatOptions): string {
|
public getLocalizedCalendarDay(options: DateTimeFormatOptions): string {
|
||||||
if (options && options.calendarType === CalendarType.Chinese) {
|
if (options && options.calendarType === CalendarType.Chinese) {
|
||||||
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayDay ?? '';
|
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.displayDay ?? '';
|
||||||
|
} else if (options && options.calendarType === CalendarType.Persian) {
|
||||||
|
return this.getPersianDateInfo().jd.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.instance.date().toString();
|
return this.instance.date().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isLocalizedCalendarFirstDayOfMonth(options: DateTimeFormatOptions): boolean {
|
||||||
|
if (options && options.calendarType === CalendarType.Chinese) {
|
||||||
|
return this.getChineseDateInfo(options.chineseCalendarLocaleData)?.day === 1;
|
||||||
|
} else if (options && options.calendarType === CalendarType.Persian) {
|
||||||
|
return this.getPersianDateInfo().jd === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.instance.date() === 1;
|
||||||
|
}
|
||||||
|
|
||||||
public getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay {
|
public getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay {
|
||||||
return (this.instance.year() + '-' + (this.instance.month() + 1).toString().padStart(2, NumeralSystem.WesternArabicNumerals.digitZero) + '-' + this.instance.date().toString().padStart(2, NumeralSystem.WesternArabicNumerals.digitZero)) as TextualYearMonthDay;
|
return (this.instance.year() + '-' + (this.instance.month() + 1).toString().padStart(2, NumeralSystem.WesternArabicNumerals.digitZero) + '-' + this.instance.date().toString().padStart(2, NumeralSystem.WesternArabicNumerals.digitZero)) as TextualYearMonthDay;
|
||||||
}
|
}
|
||||||
@@ -337,6 +360,14 @@ class MomentDateTime implements DateTime {
|
|||||||
return this.chineseDateInfo;
|
return this.chineseDateInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getPersianDateInfo(): JalaaliDateObject {
|
||||||
|
if (!this.persianDateInfo) {
|
||||||
|
this.persianDateInfo = jalaali.toJalaali(this.instance.year(), this.instance.month() + 1, this.instance.date());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.persianDateInfo;
|
||||||
|
}
|
||||||
|
|
||||||
static isYearFirstTime(dateTime: MomentDateTime): boolean {
|
static isYearFirstTime(dateTime: MomentDateTime): boolean {
|
||||||
const currentUnixTime = dateTime.instance.clone().set({ millisecond: 0 }).unix();
|
const currentUnixTime = dateTime.instance.clone().set({ millisecond: 0 }).unix();
|
||||||
const expectedUnxTime = dateTime.instance.clone().set({ millisecond: 0 }).startOf('year').unix();
|
const expectedUnxTime = dateTime.instance.clone().set({ millisecond: 0 }).startOf('year').unix();
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"monthNames": [
|
||||||
|
"فروردین",
|
||||||
|
"اردیبهشت",
|
||||||
|
"خرداد",
|
||||||
|
"تیر",
|
||||||
|
"مرداد",
|
||||||
|
"شهریور",
|
||||||
|
"مهر",
|
||||||
|
"آبان",
|
||||||
|
"آذر",
|
||||||
|
"دی",
|
||||||
|
"بهمن",
|
||||||
|
"اسفند"
|
||||||
|
],
|
||||||
|
"monthShortNames": [
|
||||||
|
"فرو",
|
||||||
|
"ارد",
|
||||||
|
"خرد",
|
||||||
|
"تیر",
|
||||||
|
"مرد",
|
||||||
|
"شهر",
|
||||||
|
"مهر",
|
||||||
|
"آبا",
|
||||||
|
"آذر",
|
||||||
|
"دی",
|
||||||
|
"بهم",
|
||||||
|
"اسف"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import fa from './fa.json';
|
||||||
|
|
||||||
|
type PersianCalendarLocaleDataKey = 'monthNames' | 'monthShortNames';
|
||||||
|
type PersianCalendarLocaleData = {
|
||||||
|
[K in PersianCalendarLocaleDataKey]: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DEFAULT_CONTENT: PersianCalendarLocaleData = fa;
|
||||||
|
|
||||||
|
export const ALL_LANGUAGES: Record<string, PersianCalendarLocaleData> = {
|
||||||
|
'fa': fa
|
||||||
|
}
|
||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+54
-1
@@ -16,18 +16,25 @@ import {
|
|||||||
DEFAULT_CONTENT as CHINESE_CALENDAR_DEFAULT_CONTENT
|
DEFAULT_CONTENT as CHINESE_CALENDAR_DEFAULT_CONTENT
|
||||||
} from '@/locales/calendar/chinese/index.ts';
|
} from '@/locales/calendar/chinese/index.ts';
|
||||||
|
|
||||||
|
import {
|
||||||
|
ALL_LANGUAGES as PERSIAN_CALENDAR_ALL_LANGUAGES,
|
||||||
|
DEFAULT_CONTENT as PERSIAN_CALENDAR_DEFAULT_CONTENT
|
||||||
|
} from '@/locales/calendar/persian/index.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
TextDirection
|
TextDirection
|
||||||
} from '@/core/text.ts';
|
} from '@/core/text.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type ChineseCalendarLocaleData,
|
type ChineseCalendarLocaleData,
|
||||||
|
type PersianCalendarLocaleData,
|
||||||
CalendarType,
|
CalendarType,
|
||||||
CalendarDisplayType,
|
CalendarDisplayType,
|
||||||
DateDisplayType
|
DateDisplayType
|
||||||
} from '@/core/calendar.ts';
|
} from '@/core/calendar.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
type DateTime,
|
||||||
type DateTimeFormatOptions,
|
type DateTimeFormatOptions,
|
||||||
type DateTimeLocaleData,
|
type DateTimeLocaleData,
|
||||||
type TextualYearMonth,
|
type TextualYearMonth,
|
||||||
@@ -174,7 +181,9 @@ import {
|
|||||||
getBrowserTimezoneOffset,
|
getBrowserTimezoneOffset,
|
||||||
getBrowserTimezoneOffsetMinutes,
|
getBrowserTimezoneOffsetMinutes,
|
||||||
getCurrentUnixTime,
|
getCurrentUnixTime,
|
||||||
|
getYearMonthDayDateTime,
|
||||||
parseDateTimeFromUnixTime,
|
parseDateTimeFromUnixTime,
|
||||||
|
getGregorianCalendarYearMonthDays,
|
||||||
getDateTimeFormatType,
|
getDateTimeFormatType,
|
||||||
getFiscalYearTimeRangeFromUnixTime,
|
getFiscalYearTimeRangeFromUnixTime,
|
||||||
getFiscalYearTimeRangeFromYear,
|
getFiscalYearTimeRangeFromYear,
|
||||||
@@ -481,6 +490,16 @@ export function useI18n() {
|
|||||||
return chineseCalendarLocaleData;
|
return chineseCalendarLocaleData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPersianCalendarLocaleData(): PersianCalendarLocaleData {
|
||||||
|
const localeData = PERSIAN_CALENDAR_ALL_LANGUAGES[locale.value] ?? PERSIAN_CALENDAR_DEFAULT_CONTENT;
|
||||||
|
const persianCalendarLocaleData: PersianCalendarLocaleData = {
|
||||||
|
monthNames: localeData['monthNames'],
|
||||||
|
monthShortNames: localeData['monthShortNames']
|
||||||
|
};
|
||||||
|
|
||||||
|
return persianCalendarLocaleData;
|
||||||
|
}
|
||||||
|
|
||||||
function getAllCurrencyDisplayTypes(numeralSystem: NumeralSystem, decimalSeparator: string): TypeAndDisplayName[] {
|
function getAllCurrencyDisplayTypes(numeralSystem: NumeralSystem, decimalSeparator: string): TypeAndDisplayName[] {
|
||||||
const defaultCurrencyDisplayTypeName = t('default.currencyDisplayType');
|
const defaultCurrencyDisplayTypeName = t('default.currencyDisplayType');
|
||||||
let defaultCurrencyDisplayType = CurrencyDisplayType.parse(defaultCurrencyDisplayTypeName);
|
let defaultCurrencyDisplayType = CurrencyDisplayType.parse(defaultCurrencyDisplayTypeName);
|
||||||
@@ -713,7 +732,8 @@ export function useI18n() {
|
|||||||
numeralSystem: numeralSystem,
|
numeralSystem: numeralSystem,
|
||||||
calendarType: calendarType,
|
calendarType: calendarType,
|
||||||
localeData: getDateTimeLocaleData(),
|
localeData: getDateTimeLocaleData(),
|
||||||
chineseCalendarLocaleData: getChineseCalendarLocaleData()
|
chineseCalendarLocaleData: getChineseCalendarLocaleData(),
|
||||||
|
persianCalendarLocaleData: getPersianCalendarLocaleData()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,6 +793,24 @@ export function useI18n() {
|
|||||||
return currencyDisplayType;
|
return currencyDisplayType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCalendarAlternateDisplayDate(dateTime: DateTime, dateTimeFormatOptions: DateTimeFormatOptions): CalendarAlternateDate {
|
||||||
|
const numeralSystem = getCurrentNumeralSystemType();
|
||||||
|
let displayDate = numeralSystem.replaceWesternArabicDigitsToLocalizedDigits(dateTime.getLocalizedCalendarDay(dateTimeFormatOptions));
|
||||||
|
|
||||||
|
if (dateTime.isLocalizedCalendarFirstDayOfMonth(dateTimeFormatOptions)) {
|
||||||
|
displayDate = dateTime.getLocalizedCalendarMonthDisplayShortName(dateTimeFormatOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
const alternateDate: CalendarAlternateDate = {
|
||||||
|
year: dateTime.getGregorianCalendarYear(),
|
||||||
|
month: dateTime.getGregorianCalendarMonth(),
|
||||||
|
day: dateTime.getGregorianCalendarDay(),
|
||||||
|
displayDate: displayDate
|
||||||
|
};
|
||||||
|
|
||||||
|
return alternateDate;
|
||||||
|
}
|
||||||
|
|
||||||
// public functions
|
// public functions
|
||||||
function translateIf(text: string | undefined, isTranslate?: boolean): string {
|
function translateIf(text: string | undefined, isTranslate?: boolean): string {
|
||||||
if (!isDefined(text)) {
|
if (!isDefined(text)) {
|
||||||
@@ -1922,6 +1960,17 @@ export function useI18n() {
|
|||||||
ret.push(alternateDate);
|
ret.push(alternateDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
} else if (calendarDisplayType === CalendarType.Persian) {
|
||||||
|
const dateTimeFormatOptions = getDateTimeFormatOptions();
|
||||||
|
const monthDays: number = getGregorianCalendarYearMonthDays(yearMonth);
|
||||||
|
const ret: CalendarAlternateDate[] = [];
|
||||||
|
|
||||||
|
for (let i = 1; i <= monthDays; i++) {
|
||||||
|
const dateTime = getYearMonthDayDateTime(yearMonth.year, yearMonth.month1base, i);
|
||||||
|
ret.push(getCalendarAlternateDisplayDate(dateTime, dateTimeFormatOptions));
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1944,6 +1993,10 @@ export function useI18n() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return getChineseCalendarAlternateDisplayDate(chineseDate);
|
return getChineseCalendarAlternateDisplayDate(chineseDate);
|
||||||
|
} else if (calendarDisplayType === CalendarType.Persian) {
|
||||||
|
const dateTimeFormatOptions = getDateTimeFormatOptions();
|
||||||
|
const dateTime = getYearMonthDayDateTime(yearMonthDay.year, yearMonthDay.month, yearMonthDay.day);
|
||||||
|
return getCalendarAlternateDisplayDate(dateTime, dateTimeFormatOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
+3
-1
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "Gregorian",
|
"Gregorian": "Gregorian",
|
||||||
"Buddhist": "Buddhist",
|
"Buddhist": "Buddhist",
|
||||||
"Gregorian with Chinese": "Gregorian with Chinese"
|
"Persian": "Persian",
|
||||||
|
"Gregorian with Chinese": "Gregorian with Chinese",
|
||||||
|
"Gregorian with Persian": "Gregorian with Persian"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "公历",
|
"Gregorian": "公历",
|
||||||
"Buddhist": "佛教日历",
|
"Buddhist": "佛教日历",
|
||||||
"Gregorian with Chinese": "公历+农历"
|
"Persian": "伊朗历",
|
||||||
|
"Gregorian with Chinese": "公历+农历",
|
||||||
|
"Gregorian with Persian": "公历+伊朗历"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
@@ -139,7 +139,9 @@
|
|||||||
"calendar": {
|
"calendar": {
|
||||||
"Gregorian": "公曆",
|
"Gregorian": "公曆",
|
||||||
"Buddhist": "佛曆",
|
"Buddhist": "佛曆",
|
||||||
"Gregorian with Chinese": "公曆+農曆"
|
"Persian": "伊朗曆",
|
||||||
|
"Gregorian with Chinese": "公曆+農曆",
|
||||||
|
"Gregorian with Persian": "公曆+伊朗曆"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"AM": {
|
"AM": {
|
||||||
|
|||||||
@@ -307,6 +307,12 @@
|
|||||||
"url": "https://github.com/faisalman/ua-parser-js",
|
"url": "https://github.com/faisalman/ua-parser-js",
|
||||||
"licenseUrl": "https://github.com/faisalman/ua-parser-js/blob/1.0.39/license.md"
|
"licenseUrl": "https://github.com/faisalman/ua-parser-js/blob/1.0.39/license.md"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Jalaali JavaScript",
|
||||||
|
"copyright": "Copyright (c) 2020 Behrang Norouzinia",
|
||||||
|
"url": "https://github.com/jalaali/jalaali-js",
|
||||||
|
"licenseUrl": "https://github.com/jalaali/jalaali-js/blob/v1.2.8/LICENSE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Materio - Vuetify VueJS 3 Free Admin Template",
|
"name": "Materio - Vuetify VueJS 3 Free Admin Template",
|
||||||
"copyright": "Copyright (c) 2022 ThemeSelection",
|
"copyright": "Copyright (c) 2022 ThemeSelection",
|
||||||
|
|||||||
Reference in New Issue
Block a user