@midseelee/date-fns-buddhist-adapter 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
```
|
|
2
|
-
|
|
3
|
-
```
|
|
4
|
-
|
|
5
1
|
# @midseelee/date-fns-buddhist-adapter
|
|
6
2
|
|
|
7
3
|
> Forked from [ascendcorp/date-fns-buddhist-adapter](https://github.com/ascendcorp/date-fns-buddhist-adapter)
|
|
@@ -11,13 +7,21 @@ date-fns adapter with Buddhist years functionality compatible with [MUI-X](https
|
|
|
11
7
|
## Installation
|
|
12
8
|
|
|
13
9
|
```shell
|
|
14
|
-
npm install @midseelee/date-fns-buddhist-adapter
|
|
10
|
+
npm install @midseelee/date-fns-buddhist-adapter date-fns@4.1.0 @date-io/date-fns@3.2.1
|
|
15
11
|
# or
|
|
16
|
-
pnpm add @midseelee/date-fns-buddhist-adapter
|
|
12
|
+
pnpm add @midseelee/date-fns-buddhist-adapter date-fns@4.1.0 @date-io/date-fns@3.2.1
|
|
17
13
|
# or
|
|
18
|
-
bun add @midseelee/date-fns-buddhist-adapter
|
|
14
|
+
bun add @midseelee/date-fns-buddhist-adapter date-fns@4.1.0 @date-io/date-fns@3.2.1
|
|
19
15
|
```
|
|
20
16
|
|
|
17
|
+
## Peer Dependencies
|
|
18
|
+
|
|
19
|
+
This package requires the following peer dependencies:
|
|
20
|
+
|
|
21
|
+
- `@mui/material` ^7.3.4
|
|
22
|
+
- `@mui/x-date-pickers` ^8.14.1
|
|
23
|
+
- `react` ^19.2.0
|
|
24
|
+
|
|
21
25
|
## Usage
|
|
22
26
|
|
|
23
27
|
```typescript
|
|
@@ -176,9 +176,7 @@ export type AdapterOptions<TLocale, TInstance> = {
|
|
|
176
176
|
formats?: Partial<AdapterFormats>;
|
|
177
177
|
locale?: TLocale;
|
|
178
178
|
} & PropertyIfNotNever<'instance', TInstance>;
|
|
179
|
-
export type DateBuilderReturnType<T extends string | null | undefined, TDate> = [
|
|
180
|
-
T
|
|
181
|
-
] extends [null] ? null : TDate;
|
|
179
|
+
export type DateBuilderReturnType<T extends string | null | undefined, TDate> = [T] extends [null] ? null : TDate;
|
|
182
180
|
export interface MuiPickersAdapter<TDate, TLocale = any> {
|
|
183
181
|
/**
|
|
184
182
|
* A boolean confirming that the adapter used is an MUI adapter.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midseelee/date-fns-buddhist-adapter",
|
|
3
3
|
"repository": "git@github.com:Sh0ckWaveZero/date-fns-buddhist-adapter.git",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"description": "date-fns adapter with Buddhist years functionality",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"LICENSE"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"test": "jest",
|
|
16
|
-
"test:watch": "jest --watch",
|
|
17
|
-
"test:coverage": "jest --coverage",
|
|
15
|
+
"test": "TZ=UTC jest",
|
|
16
|
+
"test:watch": "TZ=UTC jest --watch",
|
|
17
|
+
"test:coverage": "TZ=UTC jest --coverage",
|
|
18
18
|
"build": "tsc",
|
|
19
19
|
"build:watch": "tsc --watch",
|
|
20
20
|
"dev": "tsc --watch",
|
|
@@ -42,14 +42,17 @@
|
|
|
42
42
|
"author": "midseelee",
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
46
|
-
"
|
|
45
|
+
"node": ">=18.0.0",
|
|
46
|
+
"bun": ">=1.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@date-io/date-fns": "3.2.1",
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
"date-fns": "4.1.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@mui/material": "^7.3.4",
|
|
54
|
+
"@mui/x-date-pickers": "^8.14.1",
|
|
55
|
+
"react": "^19.2.0"
|
|
53
56
|
},
|
|
54
57
|
"devDependencies": {
|
|
55
58
|
"@eslint/js": "9.37.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { th } from 'date-fns/locale';
|
|
2
|
-
import AdapterDateFns from '..';
|
|
3
|
-
describe('AdapterDateFns', () => {
|
|
4
|
-
describe('Default locale', () => {
|
|
5
|
-
const adapter = new AdapterDateFns();
|
|
6
|
-
let date;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
date = adapter.date('2023-06-09T23:44:00.000Z');
|
|
9
|
-
});
|
|
10
|
-
it('getWeekdays: should start on Sunday', () => {
|
|
11
|
-
const result = adapter.getWeekdays();
|
|
12
|
-
expect(result).toStrictEqual(['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']);
|
|
13
|
-
});
|
|
14
|
-
it('getWeekArray: should start on Sunday', () => {
|
|
15
|
-
const result = adapter.getWeekArray(date);
|
|
16
|
-
expect(adapter.formatByString(result[0][0], 'EEEEEE')).toEqual('Su');
|
|
17
|
-
});
|
|
18
|
-
it('is12HourCycleInCurrentLocale: should have meridiem', () => {
|
|
19
|
-
expect(adapter.is12HourCycleInCurrentLocale()).toEqual(true);
|
|
20
|
-
});
|
|
21
|
-
it('should formatting correctly', () => {
|
|
22
|
-
const expectDate = (format, expected) => {
|
|
23
|
-
expect(adapter.format(date, format)).toEqual(expected);
|
|
24
|
-
};
|
|
25
|
-
expectDate('fullDate', 'Jun 10, 2566');
|
|
26
|
-
expectDate('fullDateWithWeekday', 'Saturday, June 10th, 2566');
|
|
27
|
-
expectDate('fullDateTime', 'Jun 10, 2566 6:44 AM');
|
|
28
|
-
expectDate('fullDateTime12h', 'Jun 10, 2566 06:44 am');
|
|
29
|
-
expectDate('fullDateTime24h', 'Jun 10, 2566 06:44');
|
|
30
|
-
expectDate('keyboardDate', '06/10/2566');
|
|
31
|
-
expectDate('keyboardDateTime', '06/10/2566 6:44 AM');
|
|
32
|
-
expectDate('keyboardDateTime12h', '06/10/2566 06:44 am');
|
|
33
|
-
expectDate('keyboardDateTime24h', '06/10/2566 06:44');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe('TH locale', () => {
|
|
37
|
-
const adapter = new AdapterDateFns({ locale: th });
|
|
38
|
-
let date;
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
date = adapter.date('2023-06-09T23:44:00.000Z');
|
|
41
|
-
});
|
|
42
|
-
it('getWeekdays: should start on วันอาทิตย์', () => {
|
|
43
|
-
const result = adapter.getWeekdays();
|
|
44
|
-
expect(result).toStrictEqual(['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.']);
|
|
45
|
-
});
|
|
46
|
-
it('getWeekArray: should start on วันอาทิตย์', () => {
|
|
47
|
-
const result = adapter.getWeekArray(date);
|
|
48
|
-
expect(adapter.formatByString(result[0][0], 'EEEEEE')).toEqual('อา.');
|
|
49
|
-
});
|
|
50
|
-
it('is12HourCycleInCurrentLocale: should have not meridiem', () => {
|
|
51
|
-
expect(adapter.is12HourCycleInCurrentLocale()).toEqual(false);
|
|
52
|
-
});
|
|
53
|
-
it('should formatting correctly', () => {
|
|
54
|
-
const expectDate = (format, expected) => {
|
|
55
|
-
expect(adapter.format(date, format)).toEqual(expected);
|
|
56
|
-
};
|
|
57
|
-
expectDate('fullDate', '10 มิ.ย. 2566');
|
|
58
|
-
expectDate('fullDateWithWeekday', 'วันเสาร์ที่ 10 มิถุนายน 2566');
|
|
59
|
-
expectDate('fullDateTime', '10 มิ.ย. 2566 6:44 น.');
|
|
60
|
-
expectDate('fullDateTime12h', '10 มิ.ย. 2566 06:44 ก่อนเที่ยง');
|
|
61
|
-
expectDate('fullDateTime24h', '10 มิ.ย. 2566 06:44');
|
|
62
|
-
expectDate('keyboardDate', '10/06/2566');
|
|
63
|
-
expectDate('keyboardDateTime', '10/06/2566 6:44 น.');
|
|
64
|
-
expectDate('keyboardDateTime12h', '10/06/2566 06:44 ก่อนเที่ยง');
|
|
65
|
-
expectDate('keyboardDateTime24h', '10/06/2566 06:44');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=index.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../src/__tests__/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,cAAc,MAAM,IAAI,CAAA;AAG/B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAA;QACpC,IAAI,IAAU,CAAA;QACd,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAS,CAAA;QACzD,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;YACpC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;QAC1E,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;YACzC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC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