@kuroson/sydneydayjs 0.1.0 → 0.1.3
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/CHANGELOG.md +19 -0
- package/README.md +7 -7
- package/package.json +48 -48
- package/.prettierignore +0 -5
- package/eslint.config.mjs +0 -97
- package/src/index.ts +0 -14
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -24
- package/tsup.config.ts +0 -16
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -15,19 +15,19 @@ yarn add @kuroson/sydneydayjs
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { sydneyDayjs } from
|
|
18
|
+
import { sydneyDayjs } from "@kuroson/sydneydayjs";
|
|
19
19
|
|
|
20
20
|
// Get current time in Sydney timezone
|
|
21
21
|
const now = sydneyDayjs.now();
|
|
22
|
-
console.log(now.format(
|
|
22
|
+
console.log(now.format("YYYY-MM-DD HH:mm:ss")); // e.g., "2024-01-15 14:30:00"
|
|
23
23
|
|
|
24
24
|
// Create a date in Sydney timezone
|
|
25
|
-
const date = sydneyDayjs.create(
|
|
26
|
-
console.log(date.format(
|
|
25
|
+
const date = sydneyDayjs.create("2024-06-15");
|
|
26
|
+
console.log(date.format("YYYY-MM-DD HH:mm:ss Z")); // "2024-06-15 00:00:00 +10:00"
|
|
27
27
|
|
|
28
28
|
// All standard dayjs methods are available
|
|
29
|
-
console.log(now.add(1,
|
|
30
|
-
console.log(now.startOf(
|
|
29
|
+
console.log(now.add(1, "day").format("dddd")); // e.g., "Tuesday"
|
|
30
|
+
console.log(now.startOf("month").format("YYYY-MM-DD")); // e.g., "2024-01-01"
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## API
|
|
@@ -46,7 +46,7 @@ Creates a dayjs instance from the given date input, interpreted in Sydney timezo
|
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
48
|
// From string
|
|
49
|
-
const date1 = sydneyDayjs.create(
|
|
49
|
+
const date1 = sydneyDayjs.create("2024-06-15");
|
|
50
50
|
|
|
51
51
|
// From Date object
|
|
52
52
|
const date2 = sydneyDayjs.create(new Date());
|
package/package.json
CHANGED
|
@@ -1,46 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuroson/sydneydayjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A pre-configured dayjs wrapper with Sydney (Australia/Sydney) timezone as the default",
|
|
5
5
|
"author": "Alvin Cherk <a.cherk@unsw.edu.au>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "./
|
|
9
|
-
"module": "./
|
|
10
|
-
"types": "./
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
|
-
".":
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/index.d.cts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
13
22
|
"./package.json": "./package.json"
|
|
14
23
|
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=22"
|
|
17
|
-
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsup",
|
|
20
|
-
"build:all": "tsup",
|
|
21
|
-
"lint": "eslint './**/*.{ts,js}'",
|
|
22
|
-
"lint:fix": "eslint './**/*.{ts,js}' --fix",
|
|
23
|
-
"prepublishOnly": "pnpm run build",
|
|
24
|
-
"typecheck": "tsc --noEmit"
|
|
25
|
-
},
|
|
26
24
|
"dependencies": {
|
|
27
25
|
"dayjs": "^1.11.10"
|
|
28
26
|
},
|
|
29
27
|
"devDependencies": {
|
|
30
|
-
"@eslint/js": "
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"eslint": "
|
|
36
|
-
"eslint-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"tsup": "catalog:",
|
|
42
|
-
"typescript": "catalog:",
|
|
43
|
-
"typescript-eslint": "catalog:"
|
|
28
|
+
"@eslint/js": "9.39.2",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "8.50.0",
|
|
30
|
+
"depcheck": "1.4.7",
|
|
31
|
+
"eslint": "9.39.2",
|
|
32
|
+
"eslint-config-prettier": "10.1.8",
|
|
33
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
34
|
+
"eslint-plugin-unused-imports": "4.3.0",
|
|
35
|
+
"prettier": "3.7.4",
|
|
36
|
+
"tsup": "8.5.1",
|
|
37
|
+
"typescript": "5.9.3",
|
|
38
|
+
"typescript-eslint": "8.50.0"
|
|
44
39
|
},
|
|
45
40
|
"peerDependencies": {
|
|
46
41
|
"typescript": ">=4.7.0"
|
|
@@ -51,22 +46,27 @@
|
|
|
51
46
|
}
|
|
52
47
|
},
|
|
53
48
|
"publishConfig": {
|
|
54
|
-
"access": "public"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"depcheck": {
|
|
52
|
+
"ignores": [],
|
|
53
|
+
"skip-missing": true
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=22"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"package.json",
|
|
61
|
+
"README.md",
|
|
62
|
+
"LICENSE",
|
|
63
|
+
"CHANGELOG.md"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build:all": "tsup",
|
|
67
|
+
"depcheck": "depcheck",
|
|
68
|
+
"lint": "eslint './**/*.{ts,js}'",
|
|
69
|
+
"lint:fix": "eslint './**/*.{ts,js}' --fix",
|
|
70
|
+
"typecheck": "tsc --noEmit"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|
package/.prettierignore
DELETED
package/eslint.config.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url';
|
|
2
|
-
import { dirname } from 'path';
|
|
3
|
-
import js from '@eslint/js';
|
|
4
|
-
import tseslint from 'typescript-eslint';
|
|
5
|
-
import unusedImports from 'eslint-plugin-unused-imports';
|
|
6
|
-
import prettier from 'eslint-config-prettier';
|
|
7
|
-
import prettierPlugin from 'eslint-plugin-prettier';
|
|
8
|
-
import { defineConfig } from 'eslint/config';
|
|
9
|
-
|
|
10
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
|
|
12
|
-
const config = defineConfig([
|
|
13
|
-
js.configs.recommended,
|
|
14
|
-
...tseslint.configs.recommendedTypeChecked,
|
|
15
|
-
...tseslint.configs.stylisticTypeChecked,
|
|
16
|
-
prettier,
|
|
17
|
-
{
|
|
18
|
-
ignores: [
|
|
19
|
-
'node_modules',
|
|
20
|
-
'**/node_modules',
|
|
21
|
-
'**/.cache',
|
|
22
|
-
'build',
|
|
23
|
-
'dist',
|
|
24
|
-
'.yarn',
|
|
25
|
-
'.turbo',
|
|
26
|
-
'**/.turbo',
|
|
27
|
-
'.out',
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
languageOptions: {
|
|
32
|
-
parser: tseslint.parser,
|
|
33
|
-
parserOptions: {
|
|
34
|
-
project: './tsconfig.json',
|
|
35
|
-
tsconfigRootDir: __dirname,
|
|
36
|
-
ecmaVersion: 'latest',
|
|
37
|
-
sourceType: 'module',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
plugins: {
|
|
41
|
-
'unused-imports': unusedImports,
|
|
42
|
-
prettier: prettierPlugin,
|
|
43
|
-
},
|
|
44
|
-
rules: {
|
|
45
|
-
'unused-imports/no-unused-imports': 'warn',
|
|
46
|
-
'prettier/prettier': 'error',
|
|
47
|
-
// Allow both type and interface (prefer type)
|
|
48
|
-
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
49
|
-
// Allow both Array<T> and T[] syntax
|
|
50
|
-
'@typescript-eslint/array-type': 'off',
|
|
51
|
-
// Allow both index signatures and Record types
|
|
52
|
-
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
|
53
|
-
// Allow unused variables
|
|
54
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
55
|
-
// Allow template literal expressions with any type
|
|
56
|
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
57
|
-
// Allow explicit any types
|
|
58
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
59
|
-
// Allow unsafe member access on any types
|
|
60
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
61
|
-
// Allow unsafe argument types
|
|
62
|
-
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
63
|
-
// Allow promise rejections with non-Error values
|
|
64
|
-
'@typescript-eslint/prefer-promise-reject-errors': 'off',
|
|
65
|
-
// Strict boolean expressions
|
|
66
|
-
'@typescript-eslint/strict-boolean-expressions': 'warn',
|
|
67
|
-
// Code quality
|
|
68
|
-
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
|
69
|
-
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
70
|
-
'prefer-const': 'error',
|
|
71
|
-
'no-var': 'error',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
files: ['*.js', '*.cjs'],
|
|
76
|
-
languageOptions: {
|
|
77
|
-
parserOptions: {
|
|
78
|
-
ecmaVersion: 'latest',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
...tseslint.configs.disableTypeChecked,
|
|
82
|
-
rules: {
|
|
83
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
files: ['*.config.ts', '*.config.mjs'],
|
|
88
|
-
languageOptions: {
|
|
89
|
-
parserOptions: {
|
|
90
|
-
project: null,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
...tseslint.configs.disableTypeChecked,
|
|
94
|
-
},
|
|
95
|
-
]);
|
|
96
|
-
|
|
97
|
-
export default config;
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import timezone from 'dayjs/plugin/timezone';
|
|
3
|
-
import utc from 'dayjs/plugin/utc';
|
|
4
|
-
|
|
5
|
-
const TIME_ZONE = 'Australia/Sydney';
|
|
6
|
-
|
|
7
|
-
dayjs.extend(utc);
|
|
8
|
-
dayjs.extend(timezone);
|
|
9
|
-
dayjs.tz.setDefault(TIME_ZONE);
|
|
10
|
-
|
|
11
|
-
export const sydneyDayjs = {
|
|
12
|
-
now: () => dayjs.tz(new Date(), TIME_ZONE).tz(TIME_ZONE),
|
|
13
|
-
create: (date: Parameters<typeof dayjs>[0]) => dayjs.tz(date, TIME_ZONE),
|
|
14
|
-
};
|
package/tsconfig.build.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "./tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"baseUrl": "./src",
|
|
6
|
-
"target": "ESNext",
|
|
7
|
-
"verbatimModuleSyntax": true,
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"outDir": "./dist",
|
|
11
|
-
"rootDir": "./src",
|
|
12
|
-
"declarationDir": "./dist",
|
|
13
|
-
"noEmit": false,
|
|
14
|
-
"incremental": true,
|
|
15
|
-
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo"
|
|
16
|
-
},
|
|
17
|
-
"exclude": ["dist", "**/__tests__/*", "node_modules"]
|
|
18
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "../../../tsconfig.base.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "bundler",
|
|
7
|
-
"target": "ESNext",
|
|
8
|
-
"lib": ["ESNext"],
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"baseUrl": "./src",
|
|
12
|
-
"outDir": "./dist",
|
|
13
|
-
"rootDir": "./src",
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"incremental": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"strict": true,
|
|
18
|
-
"skipLibCheck": true,
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"declarationMap": true
|
|
21
|
-
},
|
|
22
|
-
"exclude": ["**/node_modules", "**/.*/*", "dist", "tsup.config.ts"],
|
|
23
|
-
"include": ["src/**/*.ts"]
|
|
24
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup';
|
|
2
|
-
|
|
3
|
-
export default defineConfig(() => ({
|
|
4
|
-
entry: ['src/index.ts'],
|
|
5
|
-
format: ['esm', 'cjs'],
|
|
6
|
-
splitting: false,
|
|
7
|
-
clean: true,
|
|
8
|
-
dts: true,
|
|
9
|
-
platform: 'node',
|
|
10
|
-
target: 'node22',
|
|
11
|
-
tsconfig: new URL('tsconfig.build.json', import.meta.url).pathname,
|
|
12
|
-
sourcemap: true,
|
|
13
|
-
minify: false,
|
|
14
|
-
treeshake: true,
|
|
15
|
-
outDir: 'dist',
|
|
16
|
-
}));
|