@dative-gpi/foundation-core-services 0.0.6 → 0.0.8
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/composables/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TimeZoneFilters, TimeZoneInfos, TimeZoneInfosDTO } from "@dative-gpi/foundation-
|
|
1
|
+
import { TimeZoneFilters, TimeZoneInfos, TimeZoneInfosDTO } from "@dative-gpi/foundation-shared-domain";
|
|
2
2
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
3
|
|
|
4
4
|
import { TIME_ZONES_URL } from "../../config/urls";
|
package/config/literals/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-core-services",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@dative-gpi/bones-ui": "^0.0.50",
|
|
13
|
-
"@dative-gpi/foundation-core-domain": "0.0.
|
|
13
|
+
"@dative-gpi/foundation-core-domain": "0.0.8",
|
|
14
14
|
"@microsoft/signalr": "^8.0.0",
|
|
15
15
|
"vue": "^3.2.0",
|
|
16
16
|
"vue-router": "^4.2.5"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "b3393ad0a66fda249e1b2d3582af86e961553453"
|
|
19
19
|
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { onMounted, provide, ref, watch } from "vue";
|
|
2
|
-
|
|
3
|
-
import { TimeZoneInfos } from "@dative-gpi/foundation-core-domain/models";
|
|
4
|
-
|
|
5
|
-
import { TIME_ZONE } from "../config/literals";
|
|
6
|
-
|
|
7
|
-
let initialized = false;
|
|
8
|
-
|
|
9
|
-
const timeZone = ref<TimeZoneInfos | null>(null);
|
|
10
|
-
|
|
11
|
-
const getLocalOffset = (): string => {
|
|
12
|
-
const timeZoneName = Intl.DateTimeFormat("ia", {
|
|
13
|
-
timeZoneName: "short",
|
|
14
|
-
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
15
|
-
}).formatToParts().find((i) => i.type === "timeZoneName")?.value ?? "";
|
|
16
|
-
|
|
17
|
-
const offset = timeZoneName.slice(3);
|
|
18
|
-
if (!offset) {
|
|
19
|
-
return "UTC ";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const matchData = offset.match(/([+-])(\d+)(?::(\d+))?/);
|
|
23
|
-
if (matchData) {
|
|
24
|
-
const [_, sign, hour, minute] = matchData;
|
|
25
|
-
return `UTC ${sign}${hour.padStart(2, "0")}:${(minute ?? "").padStart(2, "0")}:00`;
|
|
26
|
-
}
|
|
27
|
-
return "UTC ";
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const useTimeZone = () => {
|
|
31
|
-
const setTimeZone = (payload: TimeZoneInfos) => {
|
|
32
|
-
localStorage.setItem(TIME_ZONE, JSON.stringify(payload));
|
|
33
|
-
timeZone.value = payload;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (!initialized) {
|
|
37
|
-
provide(TIME_ZONE, timeZone);
|
|
38
|
-
|
|
39
|
-
onMounted(() => {
|
|
40
|
-
if (timeZone.value) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (localStorage.getItem(TIME_ZONE) != null) {
|
|
44
|
-
timeZone.value = JSON.parse(localStorage.getItem(TIME_ZONE)!) as TimeZoneInfos;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
setTimeZone(new TimeZoneInfos({
|
|
48
|
-
id: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
49
|
-
offset: getLocalOffset()
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
initialized = true;
|
|
56
|
-
|
|
57
|
-
const ready = new Promise((resolve) => {
|
|
58
|
-
if (timeZone.value) {
|
|
59
|
-
resolve(timeZone.value);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
watch(timeZone, () => {
|
|
63
|
-
if (timeZone.value) {
|
|
64
|
-
resolve(timeZone.value);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
ready,
|
|
72
|
-
timeZone,
|
|
73
|
-
setTimeZone
|
|
74
|
-
};
|
|
75
|
-
}
|