@olenbetong/appframe-core 2.4.1 → 2.4.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/es/date.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export declare function toLocalISODate(date: Date): string;
2
+ export declare function toLocalISODate(date: null): null;
2
3
  export declare function toLocalISODateTime(date: Date): string;
4
+ export declare function toLocalISODateTime(date: null): null;
package/es/date.js CHANGED
@@ -1,12 +1,11 @@
1
1
  export function toLocalISODate(date) {
2
- return toLocalISODateTime(date).substring(0, 10);
2
+ return date ? toLocalISODateTime(date).substring(0, 10) : null;
3
+ }
4
+ function pad(num) {
5
+ return String(num).padStart(2, "0");
3
6
  }
4
7
  export function toLocalISODateTime(date) {
5
- let newDate = new Date(date);
6
- newDate.setUTCFullYear(date.getFullYear());
7
- newDate.setUTCMonth(date.getMonth());
8
- newDate.setUTCDate(date.getDate());
9
- newDate.setUTCHours(date.getHours());
10
- newDate.setUTCMinutes(date.getMinutes());
11
- return newDate.toISOString().replace("Z", "");
8
+ return date
9
+ ? `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds())}`
10
+ : null;
12
11
  }
package/es/index.js CHANGED
@@ -14,4 +14,4 @@ export { default as localStorage } from "./localStorage.js";
14
14
  export { default as SessionHandler } from "./SessionHandler.js";
15
15
  export { UserSession };
16
16
  export * from "./settings.js";
17
- export const version = "2.4.1";
17
+ export const version = "2.4.3";
package/es/localize.js CHANGED
@@ -14,7 +14,7 @@ import { invariant } from "./invariant.js";
14
14
  * @returns Translated string
15
15
  */
16
16
  export function localize(stringParts, ...args) {
17
- invariant(!Array.isArray(stringParts) || stringParts.length !== args.length + 1, "Method 'localize' must be used as a tag function");
17
+ invariant(Array.isArray(stringParts) && stringParts.length === args.length + 1, "Method 'localize' must be used as a tag function");
18
18
  let stringToLocalize = stringParts.map((s, i) => (i === stringParts.length - 1 ? s : `${s}\$${i}`)).join("");
19
19
  let localized = getLocalizedString(stringToLocalize);
20
20
  args.forEach((arg, index) => {
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
1
  {
2
- "name": "@olenbetong/appframe-core",
3
- "version": "2.4.1",
4
- "description": "Javascript libraries to utilize the Appframe framework",
5
- "type": "module",
6
- "sideEffects": [
7
- "/src/errorHandler.ts"
8
- ],
9
- "main": "./es/index.js",
10
- "exports": {
11
- ".": {
12
- "default": "./es/index.js"
13
- }
14
- },
15
- "types": "./es/index.d.ts",
16
- "scripts": {
17
- "prepack": "npm run build",
18
- "build": "npm run build:esbuild && npm run build:tsc",
19
- "build:esbuild": "node --loader ts-node/esm.mjs ../../shared/esbuild.ts",
20
- "build:tsc": " rm -rf ./es && tsc && node ./scripts/replace-version.js"
21
- },
22
- "files": [
23
- "dist",
24
- "es",
25
- "src"
26
- ],
27
- "author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
28
- "repository": {
29
- "type": "git",
30
- "url": "https://github.com/olenbetong/ui-kit.git"
31
- },
32
- "license": "MIT",
33
- "buildConfig": {
34
- "entries": [
35
- {
36
- "libraryName": "af.common"
37
- },
38
- {
39
- "libraryName": "af.common",
40
- "outfile": "af.common.legacy",
41
- "target": "safari11"
42
- }
43
- ]
44
- },
45
- "dependencies": {
46
- "mitt": "^3.0.0"
47
- },
48
- "devDependencies": {
49
- "chalk": "^5.1.2"
50
- },
51
- "gitHead": "7791085160a65a855eab8c32801abcfd8f8b2c3c"
2
+ "name": "@olenbetong/appframe-core",
3
+ "version": "2.4.3",
4
+ "description": "Javascript libraries to utilize the Appframe framework",
5
+ "type": "module",
6
+ "sideEffects": [
7
+ "/src/errorHandler.ts"
8
+ ],
9
+ "main": "./es/index.js",
10
+ "exports": {
11
+ ".": {
12
+ "default": "./es/index.js"
13
+ }
14
+ },
15
+ "types": "./es/index.d.ts",
16
+ "scripts": {
17
+ "prepack": "npm run build",
18
+ "build": "npm run build:esbuild && npm run build:tsc",
19
+ "build:esbuild": "node --loader ts-node/esm.mjs ../../shared/esbuild.ts",
20
+ "build:tsc": " rm -rf ./es && tsc && node ./scripts/replace-version.js"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "es",
25
+ "src"
26
+ ],
27
+ "author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/olenbetong/ui-kit.git"
31
+ },
32
+ "license": "MIT",
33
+ "buildConfig": {
34
+ "entries": [
35
+ {
36
+ "libraryName": "af.common"
37
+ },
38
+ {
39
+ "libraryName": "af.common",
40
+ "outfile": "af.common.legacy",
41
+ "target": "safari11"
42
+ }
43
+ ]
44
+ },
45
+ "dependencies": {
46
+ "mitt": "^3.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "chalk": "^5.1.2"
50
+ },
51
+ "gitHead": "1d17062e6d3a5bee1264d25572ec08ea2635f1ca"
52
52
  }
package/src/date.ts CHANGED
@@ -1,14 +1,19 @@
1
- export function toLocalISODate(date: Date) {
2
- return toLocalISODateTime(date).substring(0, 10);
1
+ export function toLocalISODate(date: Date): string;
2
+ export function toLocalISODate(date: null): null;
3
+ export function toLocalISODate(date: Date | null): string | null {
4
+ return date ? toLocalISODateTime(date).substring(0, 10) : null;
3
5
  }
4
6
 
5
- export function toLocalISODateTime(date: Date) {
6
- let newDate = new Date(date);
7
- newDate.setUTCFullYear(date.getFullYear());
8
- newDate.setUTCMonth(date.getMonth());
9
- newDate.setUTCDate(date.getDate());
10
- newDate.setUTCHours(date.getHours());
11
- newDate.setUTCMinutes(date.getMinutes());
7
+ function pad(num: number) {
8
+ return String(num).padStart(2, "0");
9
+ }
12
10
 
13
- return newDate.toISOString().replace("Z", "");
11
+ export function toLocalISODateTime(date: Date): string;
12
+ export function toLocalISODateTime(date: null): null;
13
+ export function toLocalISODateTime(date: Date | null): string | null {
14
+ return date
15
+ ? `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(
16
+ date.getMinutes()
17
+ )}:${pad(date.getSeconds())}.${pad(date.getMilliseconds())}`
18
+ : null;
14
19
  }
package/src/localize.ts CHANGED
@@ -16,7 +16,7 @@ import { invariant } from "./invariant.js";
16
16
  */
17
17
  export function localize(stringParts: TemplateStringsArray, ...args: any[]): string {
18
18
  invariant(
19
- !Array.isArray(stringParts) || stringParts.length !== args.length + 1,
19
+ Array.isArray(stringParts) && stringParts.length === args.length + 1,
20
20
  "Method 'localize' must be used as a tag function"
21
21
  );
22
22