esoftplay 0.0.124-b → 0.0.124-d
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/modules/lib/curl.ts +10 -12
- package/moment.ts +19 -4
- package/package.json +1 -1
package/modules/lib/curl.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { LibNet_status } from 'esoftplay/cache/lib/net_status/import';
|
|
|
6
6
|
import { LibProgress } from 'esoftplay/cache/lib/progress/import';
|
|
7
7
|
import { LibToastProperty } from 'esoftplay/cache/lib/toast/import';
|
|
8
8
|
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
|
|
9
|
-
import esp from 'esoftplay/esp';
|
|
10
9
|
import { reportApiError } from "esoftplay/error";
|
|
10
|
+
import esp from 'esoftplay/esp';
|
|
11
11
|
import Constants from 'expo-constants';
|
|
12
12
|
|
|
13
13
|
//api_logger_import
|
|
@@ -441,16 +441,14 @@ export default class m {
|
|
|
441
441
|
LibProgress.hide()
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
protected getTimeByTimeZone(
|
|
445
|
-
|
|
446
|
-
let
|
|
447
|
-
let
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
let time = new Date().getTime() + (diff * 60 * 1000 * -1);
|
|
454
|
-
return time;
|
|
444
|
+
protected getTimeByTimeZone(GMT: number): number {
|
|
445
|
+
const date = new Date()
|
|
446
|
+
let currentOffsetInMinutes = date.getTimezoneOffset();
|
|
447
|
+
let currentOffsetInHours = currentOffsetInMinutes / 60;
|
|
448
|
+
let currentGMT = -currentOffsetInHours;
|
|
449
|
+
let currentOffset = currentGMT * 60 * 60 * 1000;
|
|
450
|
+
let targetOffset = 7/* Asia/Jakarta */ * 60 * 60 * 1000;
|
|
451
|
+
let gmtDiff = targetOffset - currentOffset;
|
|
452
|
+
return date.getTime() + gmtDiff
|
|
455
453
|
}
|
|
456
454
|
}
|
package/moment.ts
CHANGED
|
@@ -17,6 +17,20 @@ function isNumeric(n) {
|
|
|
17
17
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function normalizeTimeOffset(date: Date) {
|
|
21
|
+
if (!(date instanceof Date)) {
|
|
22
|
+
date = dayjs(date).toDate()
|
|
23
|
+
}
|
|
24
|
+
let currentOffsetInMinutes = date.getTimezoneOffset();
|
|
25
|
+
let currentOffsetInHours = currentOffsetInMinutes / 60;
|
|
26
|
+
let currentGMT = -currentOffsetInHours;
|
|
27
|
+
let currentOffset = currentGMT * 60 * 60 * 1000;
|
|
28
|
+
let targetOffset = 7/* Asia/Jakarta */ * 60 * 60 * 1000;
|
|
29
|
+
let gmtDiff = targetOffset - currentOffset;
|
|
30
|
+
let originalTime = new Date(date.getTime() - gmtDiff);
|
|
31
|
+
return originalTime;
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
export default function moment(date?: string | Date | any) {
|
|
21
35
|
let _date = isNumeric(date) ? new Date(date * 1000) : date
|
|
22
36
|
return {
|
|
@@ -40,11 +54,12 @@ export default function moment(date?: string | Date | any) {
|
|
|
40
54
|
},
|
|
41
55
|
/* last chain */
|
|
42
56
|
fromNow: () => {
|
|
43
|
-
const out = dayjs(_date).fromNow()
|
|
57
|
+
const out = dayjs(normalizeTimeOffset(_date)).fromNow()
|
|
44
58
|
return out
|
|
45
59
|
},
|
|
46
|
-
format: (custom: string) => {
|
|
47
|
-
const
|
|
60
|
+
format: (custom: string, ignoreTimezone?: boolean) => {
|
|
61
|
+
const _d = ignoreTimezone? _date : normalizeTimeOffset(_date)
|
|
62
|
+
const out = dayjs(_d).format(custom)
|
|
48
63
|
return out
|
|
49
64
|
},
|
|
50
65
|
toDate: () => {
|
|
@@ -52,7 +67,7 @@ export default function moment(date?: string | Date | any) {
|
|
|
52
67
|
return out
|
|
53
68
|
},
|
|
54
69
|
toMiliseconds: () => {
|
|
55
|
-
const out = String(dayjs(_date).valueOf())
|
|
70
|
+
const out = String(dayjs(normalizeTimeOffset(_date)).valueOf())
|
|
56
71
|
return out
|
|
57
72
|
},
|
|
58
73
|
duration: (other_date: string | Date) => {
|