@cloudparker/moldex.js 4.1.16 → 4.1.18
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.
|
@@ -14,10 +14,6 @@ export declare class PeriodEnum {
|
|
|
14
14
|
static NEXT_YEAR: number;
|
|
15
15
|
static DATE: number;
|
|
16
16
|
}
|
|
17
|
-
export type FirestoreTimestamp = {
|
|
18
|
-
seconds: number;
|
|
19
|
-
nanoseconds: number;
|
|
20
|
-
};
|
|
21
17
|
export declare function getDateWith(yearChange: number): Date;
|
|
22
18
|
export declare function getDateTime(date: string | Date | any): number;
|
|
23
19
|
export declare function momentDiff({ startDate, endDate, unit }: {
|
|
@@ -37,9 +33,6 @@ export declare function getPeriodDates(period: PeriodEnum, currentDate?: Date):
|
|
|
37
33
|
export declare function padTo2Digits(num: number): string;
|
|
38
34
|
export declare function millisToTimeString(milliseconds: number): string;
|
|
39
35
|
export declare function timestampToMillis(timestamp: any): number;
|
|
40
|
-
export declare function timestampToDate(timestamp: FirestoreTimestamp): Date;
|
|
41
|
-
export declare function timestampToDateString(timestamp: FirestoreTimestamp): string;
|
|
42
|
-
export declare function timestampToAgo(timestamp: FirestoreTimestamp): string;
|
|
43
36
|
export declare function dateToTimestamp(date: Date): {
|
|
44
37
|
seconds: number;
|
|
45
38
|
nanoseconds: number;
|
|
@@ -50,3 +43,9 @@ export declare function millisToDate(millis: number): Date;
|
|
|
50
43
|
export declare function dateFormat(date: Date, format?: 'MM-DD-YYYY hh:mm a' | 'MM-DD-YYYY' | 'YYYY-MM-DD' | 'YYYY-MM-DDTHH:MM' | string): string;
|
|
51
44
|
export declare function isDateBetween(date: Date, startDate: Date, endDate: Date): boolean;
|
|
52
45
|
export declare function toDate(value: any): Date;
|
|
46
|
+
/**
|
|
47
|
+
* Formats a duration in seconds to mm:ss or hh:mm:ss format
|
|
48
|
+
* @param seconds - The duration in seconds
|
|
49
|
+
* @returns Formatted duration string (mm:ss if less than an hour, hh:mm:ss if an hour or more)
|
|
50
|
+
*/
|
|
51
|
+
export declare function formatDuration(seconds: number): string;
|
|
@@ -141,21 +141,6 @@ export function timestampToMillis(timestamp) {
|
|
|
141
141
|
return (timestamp.seconds * 1000) + (timestamp.nanoseconds / 1000000);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
export function timestampToDate(timestamp) {
|
|
145
|
-
if (timestamp && timestamp.seconds) {
|
|
146
|
-
return new Date((timestamp.seconds * 1000) + (timestamp.nanoseconds / 1000000));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
export function timestampToDateString(timestamp) {
|
|
150
|
-
if (timestamp && timestamp.seconds) {
|
|
151
|
-
return moment(new Date(timestamp.seconds * 1000)).format('MM-DD-YYYY hh:mm a');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
export function timestampToAgo(timestamp) {
|
|
155
|
-
if (timestamp && timestamp.seconds) {
|
|
156
|
-
return moment(new Date(timestamp.seconds * 1000)).fromNow();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
144
|
export function dateToTimestamp(date) {
|
|
160
145
|
return { seconds: date.getTime() / 1000, nanoseconds: 0 };
|
|
161
146
|
}
|
|
@@ -198,9 +183,26 @@ export function toDate(value) {
|
|
|
198
183
|
else if (typeof value == 'string') {
|
|
199
184
|
result = moment(value).toDate();
|
|
200
185
|
}
|
|
201
|
-
else if (value.seconds) {
|
|
202
|
-
result = timestampToDate(value);
|
|
203
|
-
}
|
|
204
186
|
}
|
|
205
187
|
return result;
|
|
206
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Formats a duration in seconds to mm:ss or hh:mm:ss format
|
|
191
|
+
* @param seconds - The duration in seconds
|
|
192
|
+
* @returns Formatted duration string (mm:ss if less than an hour, hh:mm:ss if an hour or more)
|
|
193
|
+
*/
|
|
194
|
+
export function formatDuration(seconds) {
|
|
195
|
+
if (seconds < 0) {
|
|
196
|
+
seconds = 0;
|
|
197
|
+
}
|
|
198
|
+
const hours = Math.floor(seconds / 3600);
|
|
199
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
200
|
+
const secs = Math.floor(seconds % 60);
|
|
201
|
+
const mm = minutes.toString().padStart(2, '0');
|
|
202
|
+
const ss = secs.toString().padStart(2, '0');
|
|
203
|
+
if (hours > 0) {
|
|
204
|
+
const hh = hours.toString().padStart(2, '0');
|
|
205
|
+
return `${hh}:${mm}:${ss}`;
|
|
206
|
+
}
|
|
207
|
+
return `${mm}:${ss}`;
|
|
208
|
+
}
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
</script>
|
|
47
47
|
|
|
48
48
|
<EasyScriptLoader
|
|
49
|
-
scriptUrl="
|
|
49
|
+
scriptUrl="https://cdn.jsdelivr.net/gh/paramanandapradhan/easy-country-state-data@main/dist/index.js"
|
|
50
50
|
scriptName="EasyCountryStateData"
|
|
51
51
|
onLoad={handleStatesLoaded}
|
|
52
52
|
/>
|