@dative-gpi/foundation-shared-domain 1.0.6 → 1.0.9

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.
@@ -6,7 +6,6 @@ export class UserDetails extends UserInfos {
6
6
  hasSignedPolicies: boolean;
7
7
  languageCode: string;
8
8
  timeZoneId: string;
9
- timeZoneOffset: string;
10
9
  allowNotifications: boolean;
11
10
  allowSms: boolean;
12
11
  allowEmails: boolean;
@@ -18,7 +17,6 @@ export class UserDetails extends UserInfos {
18
17
  this.hasSignedPolicies = params.hasSignedPolicies;
19
18
  this.languageCode = params.languageCode;
20
19
  this.timeZoneId = params.timeZoneId;
21
- this.timeZoneOffset = params.timeZoneOffset;
22
20
  this.allowNotifications = params.allowNotifications;
23
21
  this.allowSms = params.allowSms;
24
22
  this.allowEmails = params.allowEmails;
@@ -30,7 +28,6 @@ export interface UserDetailsDTO extends UserInfosDTO {
30
28
  hasSignedPolicies: boolean;
31
29
  languageCode: string;
32
30
  timeZoneId: string;
33
- timeZoneOffset: string;
34
31
  allowNotifications: boolean;
35
32
  allowSms: boolean;
36
33
  allowEmails: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-domain",
3
3
  "sideEffects": false,
4
- "version": "1.0.6",
4
+ "version": "1.0.9",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -12,5 +12,5 @@
12
12
  "peerDependencies": {
13
13
  "date-fns": "^3.6.0"
14
14
  },
15
- "gitHead": "b2bbdea22792b7454a5234d8a6b8bb43553f3202"
15
+ "gitHead": "018a67489fc022344c90d45b02bfabdcd0dcefec"
16
16
  }
@@ -1,13 +1,51 @@
1
1
  import { parse } from "date-fns";
2
2
 
3
+ export const ISO_FORMAT: string = "yyyy-MM-dd'T'HH:mm:ss";
4
+
5
+ export const OPTIONS: { [key: string]: Intl.DateTimeFormatOptions } = {
6
+ shortDate: {
7
+ day: "2-digit",
8
+ month: "2-digit",
9
+ year: "numeric"
10
+ },
11
+ longDate: {
12
+ weekday: "long",
13
+ day: "2-digit",
14
+ month: "long",
15
+ year: "numeric"
16
+ },
17
+ shortTime: {
18
+ day: "2-digit",
19
+ month: "2-digit",
20
+ year: "numeric",
21
+ hour: "2-digit",
22
+ minute: "2-digit",
23
+ second: "2-digit"
24
+ },
25
+ longTime: {
26
+ weekday: "long",
27
+ day: "2-digit",
28
+ month: "long",
29
+ year: "numeric",
30
+ hour: "2-digit",
31
+ minute: "2-digit",
32
+ second: "2-digit"
33
+ },
34
+ time: {
35
+ hour: "2-digit",
36
+ minute: "2-digit",
37
+ second: "2-digit"
38
+ }
39
+ };
40
+
41
+ export const utcToEpoch = (value: string): number => {
42
+ return parse(value.substring(0, 19) + "Z", ISO_FORMAT + "X", new Date()).getTime();
43
+ };
44
+
3
45
  const BASE = ["now"];
4
46
  const WIDGET = ["from", "to"];
5
47
  const ALERT = ["alert", "alertstart", "alertend"];
6
48
 
7
- const removeArtifacts = (date: string): string => {
8
- return date.substring(0, 19) + "Z";
9
- };
10
-
11
49
  const fromExpression = (expression: string, variant: 'default' | 'before-after'): boolean => {
12
50
  if (
13
51
  /^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}(:\d{2})?$/g.test(expression) ||
@@ -66,14 +104,6 @@ const fromExpression = (expression: string, variant: 'default' | 'before-after')
66
104
  return true;
67
105
  };
68
106
 
69
- export const isoTimeFormat = (timeZone: boolean = false): string => {
70
- return `yyyy-MM-dd'T'HH:mm:ss${timeZone ? "X" : ""}`;
71
- };
72
-
73
- export const utcToEpoch = (value: string): number => {
74
- return parse(removeArtifacts(value), isoTimeFormat(true), new Date()).getTime();
75
- };
76
-
77
107
  export const validateExpression = (expression: string, variant: "default" | "before-after"): boolean => {
78
108
  return (fromExpression(expression!, variant));
79
109
  };