Skip to content

Commit

Permalink
chore(deps): use date-fns-jalali v3 (#669)
Browse files Browse the repository at this point in the history
* install date-fns-jalali-v3

* use date-fns-jalali-v3
  • Loading branch information
smmoosavi authored Jul 21, 2024
1 parent 634ae73 commit 2987a66
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 63 deletions.
4 changes: 2 additions & 2 deletions packages/date-fns-jalali/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"license": "MIT",
"peerDependencies": {
"date-fns-jalali": "^2.13.0-0"
"date-fns-jalali": "^3.2.0-0"
},
"peerDependenciesMeta": {
"date-fns-jalali": {
Expand All @@ -43,7 +43,7 @@
"@date-io/core": "^3.0.0"
},
"devDependencies": {
"date-fns-jalali": "^2.19.0-2",
"date-fns-jalali": "^3.2.0-0",
"rollup": "^2.0.2",
"typescript": "^5.0.0"
},
Expand Down
112 changes: 55 additions & 57 deletions packages/date-fns-jalali/src/date-fns-jalali-utils.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
import addSeconds from "date-fns-jalali/addSeconds";
import addMinutes from "date-fns-jalali/addMinutes";
import addHours from "date-fns-jalali/addHours";
import addDays from "date-fns-jalali/addDays";
import addWeeks from "date-fns-jalali/addWeeks";
import addMonths from "date-fns-jalali/addMonths";
import addYears from "date-fns-jalali/addYears";
import differenceInYears from "date-fns-jalali/differenceInYears";
import differenceInQuarters from "date-fns-jalali/differenceInQuarters";
import differenceInMonths from "date-fns-jalali/differenceInMonths";
import differenceInWeeks from "date-fns-jalali/differenceInWeeks";
import differenceInDays from "date-fns-jalali/differenceInDays";
import differenceInHours from "date-fns-jalali/differenceInHours";
import differenceInMinutes from "date-fns-jalali/differenceInMinutes";
import differenceInSeconds from "date-fns-jalali/differenceInSeconds";
import differenceInMilliseconds from "date-fns-jalali/differenceInMilliseconds";
import eachDayOfInterval from "date-fns-jalali/eachDayOfInterval";
import endOfDay from "date-fns-jalali/endOfDay";
import endOfWeek from "date-fns-jalali/endOfWeek";
import endOfYear from "date-fns-jalali/endOfYear";
import format from "date-fns-jalali/format";
import formatISO from "date-fns-jalali/formatISO";
import getHours from "date-fns-jalali/getHours";
import getSeconds from "date-fns-jalali/getSeconds";
import getYear from "date-fns-jalali/getYear";
import getMonth from "date-fns-jalali/getMonth";
import getDate from "date-fns-jalali/getDate";
import getDay from "date-fns-jalali/getDay";
import getDaysInMonth from "date-fns-jalali/getDaysInMonth";
import getMinutes from "date-fns-jalali/getMinutes";
import isAfter from "date-fns-jalali/isAfter";
import isBefore from "date-fns-jalali/isBefore";
import isEqual from "date-fns-jalali/isEqual";
import isSameDay from "date-fns-jalali/isSameDay";
import isSameYear from "date-fns-jalali/isSameYear";
import isSameMonth from "date-fns-jalali/isSameMonth";
import isSameHour from "date-fns-jalali/isSameHour";
import isValid from "date-fns-jalali/isValid";
import dateFnsParse from "date-fns-jalali/parse";
import parseISO from "date-fns-jalali/parseISO";
import setDate from "date-fns-jalali/setDate";
import setHours from "date-fns-jalali/setHours";
import setMinutes from "date-fns-jalali/setMinutes";
import setMonth from "date-fns-jalali/setMonth";
import setSeconds from "date-fns-jalali/setSeconds";
import setYear from "date-fns-jalali/setYear";
import startOfDay from "date-fns-jalali/startOfDay";
import startOfMonth from "date-fns-jalali/startOfMonth";
import endOfMonth from "date-fns-jalali/endOfMonth";
import startOfWeek from "date-fns-jalali/startOfWeek";
import startOfYear from "date-fns-jalali/startOfYear";
import { addSeconds } from "date-fns-jalali/addSeconds";
import { addMinutes } from "date-fns-jalali/addMinutes";
import { addHours } from "date-fns-jalali/addHours";
import { addDays } from "date-fns-jalali/addDays";
import { addWeeks } from "date-fns-jalali/addWeeks";
import { addMonths } from "date-fns-jalali/addMonths";
import { addYears } from "date-fns-jalali/addYears";
import { differenceInYears } from "date-fns-jalali/differenceInYears";
import { differenceInQuarters } from "date-fns-jalali/differenceInQuarters";
import { differenceInMonths } from "date-fns-jalali/differenceInMonths";
import { differenceInWeeks } from "date-fns-jalali/differenceInWeeks";
import { differenceInDays } from "date-fns-jalali/differenceInDays";
import { differenceInHours } from "date-fns-jalali/differenceInHours";
import { differenceInMinutes } from "date-fns-jalali/differenceInMinutes";
import { differenceInSeconds } from "date-fns-jalali/differenceInSeconds";
import { differenceInMilliseconds } from "date-fns-jalali/differenceInMilliseconds";
import { eachDayOfInterval } from "date-fns-jalali/eachDayOfInterval";
import { endOfDay } from "date-fns-jalali/endOfDay";
import { endOfWeek } from "date-fns-jalali/endOfWeek";
import { endOfYear } from "date-fns-jalali/endOfYear";
import { format, longFormatters } from "date-fns-jalali/format";
import { formatISO } from "date-fns-jalali/formatISO";
import { getHours } from "date-fns-jalali/getHours";
import { getSeconds } from "date-fns-jalali/getSeconds";
import { getYear } from "date-fns-jalali/getYear";
import { getMonth } from "date-fns-jalali/getMonth";
import { getDate } from "date-fns-jalali/getDate";
import { getDay } from "date-fns-jalali/getDay";
import { getDaysInMonth } from "date-fns-jalali/getDaysInMonth";
import { getMinutes } from "date-fns-jalali/getMinutes";
import { isAfter } from "date-fns-jalali/isAfter";
import { isBefore } from "date-fns-jalali/isBefore";
import { isEqual } from "date-fns-jalali/isEqual";
import { isSameDay } from "date-fns-jalali/isSameDay";
import { isSameYear } from "date-fns-jalali/isSameYear";
import { isSameMonth } from "date-fns-jalali/isSameMonth";
import { isSameHour } from "date-fns-jalali/isSameHour";
import { isValid } from "date-fns-jalali/isValid";
import { parse as dateFnsParse } from "date-fns-jalali/parse";
import { parseISO } from "date-fns-jalali/parseISO";
import { setDate } from "date-fns-jalali/setDate";
import { setHours } from "date-fns-jalali/setHours";
import { setMinutes } from "date-fns-jalali/setMinutes";
import { setMonth } from "date-fns-jalali/setMonth";
import { setSeconds } from "date-fns-jalali/setSeconds";
import { setYear } from "date-fns-jalali/setYear";
import { startOfDay } from "date-fns-jalali/startOfDay";
import { startOfMonth } from "date-fns-jalali/startOfMonth";
import { endOfMonth } from "date-fns-jalali/endOfMonth";
import { startOfWeek } from "date-fns-jalali/startOfWeek";
import { startOfYear } from "date-fns-jalali/startOfYear";
import { IUtils, DateIOFormats, Unit } from "@date-io/core/IUtils";
import isWithinInterval from "date-fns-jalali/isWithinInterval";
// @ts-ignore
import longFormatters from "date-fns-jalali/_lib/format/longFormatters";
import defaultLocale from "date-fns-jalali/locale/fa-IR";
import { isWithinInterval } from "date-fns-jalali/isWithinInterval";
import { faIR as defaultLocale } from "date-fns-jalali/locale/fa-IR";

type Locale = typeof defaultLocale;

Expand Down Expand Up @@ -117,7 +115,7 @@ export default class DateFnsJalaliUtils implements IUtils<Date, Locale> {
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
public is12HourCycleInCurrentLocale = () => {
if (this.locale) {
return /a/.test(this.locale.formatLong?.time());
return /a/.test(this.locale.formatLong?.time({}));
}

// By default date-fns-jalali is using fa-IR locale with am/pm enabled
Expand All @@ -136,7 +134,7 @@ export default class DateFnsJalaliUtils implements IUtils<Date, Locale> {
const firstCharacter = token[0];
if (firstCharacter === "p" || firstCharacter === "P") {
const longFormatter = longFormatters[firstCharacter];
return longFormatter(token, locale.formatLong, {});
return longFormatter(token, locale.formatLong);
}
return token;
})
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2736,10 +2736,10 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"

date-fns-jalali@^2.19.0-2:
version "2.19.0-2"
resolved "https://registry.yarnpkg.com/date-fns-jalali/-/date-fns-jalali-2.19.0-2.tgz#69d35c6505749e9bce485c0e392604936e20cb2a"
integrity sha512-ajgQt3lNFKPN7+mkXpWRJP+NyTVyHRJFVXUV8uc7d9pduVrDn/eeRMT5w1PemXqQRoNqQmuHyKWcrmNPmTRoPA==
date-fns-jalali@^3.2.0-0:
version "3.2.0-0"
resolved "https://registry.yarnpkg.com/date-fns-jalali/-/date-fns-jalali-3.2.0-0.tgz#5ab00c60ed491bd46e4996b19f3a21ab3ca8bb68"
integrity sha512-ufksQntsttjzp5mA8yyVEI0PGMlA6iEoBktbbDUbNs9NoDBbjwfW2IygZoENJz4K0BHMOpINfgaUSUkskYd8xg==

date-fns@^3.2.0:
version "3.4.0"
Expand Down

0 comments on commit 2987a66

Please sign in to comment.