@openmrs/esm-utils 4.0.0-pre.0 → 4.0.0-pre.1
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/.turbo/turbo-build.log +18 -18
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +10 -10
- package/.turbo/turbo-typescript.log +2 -2
- package/dist/age-helpers.d.ts +20 -0
- package/dist/index.d.ts +5 -0
- package/dist/omrs-dates.d.ts +110 -0
- package/dist/omrs-dates.test.d.ts +1 -0
- package/dist/openmrs-esm-utils.js +0 -0
- package/dist/openmrs-esm-utils.js.map +1 -1
- package/dist/retry.d.ts +38 -0
- package/dist/translate.d.ts +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.test.d.ts +1 -0
- package/package.json +2 -2
- package/src/omrs-dates.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
1
|
+
[32m@openmrs/esm-utils:build: [0mcache hit, replaying output [2m96a8c5c50f754983[0m
|
|
2
|
+
[32m@openmrs/esm-utils:build: [0m$ webpack --mode=production
|
|
3
|
+
[32m@openmrs/esm-utils:build: [0masset openmrs-esm-utils.js 47.2 KiB [emitted] [minimized] (name: main) 1 related asset
|
|
4
|
+
[32m@openmrs/esm-utils:build: [0mruntime modules 2.02 KiB 7 modules
|
|
5
|
+
[32m@openmrs/esm-utils:build: [0morphan modules 19 KiB [orphan] 5 modules
|
|
6
|
+
[32m@openmrs/esm-utils:build: [0mmodules by path ../../../node_modules/semver/ 55.8 KiB 44 modules
|
|
7
|
+
[32m@openmrs/esm-utils:build: [0mmodules by path ../../../node_modules/systemjs-webpack-interop/ 3.27 KiB
|
|
8
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
|
|
9
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
|
|
10
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
|
|
11
|
+
[32m@openmrs/esm-utils:build: [0mmodules by path ../../../node_modules/dayjs/plugin/*.js 2.56 KiB
|
|
12
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/dayjs/plugin/utc.js 2.2 KiB [built] [code generated]
|
|
13
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/dayjs/plugin/isToday.js 365 bytes [built] [code generated]
|
|
14
|
+
[32m@openmrs/esm-utils:build: [0mmodules by path ../../../node_modules/yallist/*.js 8.42 KiB
|
|
15
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/yallist/yallist.js 8.21 KiB [built] [code generated]
|
|
16
|
+
[32m@openmrs/esm-utils:build: [0m ../../../node_modules/yallist/iterator.js 207 bytes [built] [code generated]
|
|
17
|
+
[32m@openmrs/esm-utils:build: [0m+ 5 modules
|
|
18
|
+
[32m@openmrs/esm-utils:build: [0mwebpack 5.70.0 compiled successfully in 22478 ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[33m@openmrs/esm-utils:lint: [0mcache hit, replaying output [
|
|
1
|
+
[33m@openmrs/esm-utils:lint: [0mcache hit, replaying output [2m9f58a5aad569522c[0m
|
|
2
2
|
[33m@openmrs/esm-utils:lint: [0m$ eslint src --ext ts,tsx
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
1
|
+
[32m@openmrs/esm-utils:test: [0mcache hit, replaying output [2mcf5960bce80c784e[0m
|
|
2
|
+
[32m@openmrs/esm-utils:test: [0m$ jest --config jest.config.js --passWithNoTests
|
|
3
|
+
[32m@openmrs/esm-utils:test: [0mPASS src/omrs-dates.test.ts
|
|
4
|
+
[32m@openmrs/esm-utils:test: [0mPASS src/version.test.ts
|
|
5
|
+
[32m@openmrs/esm-utils:test: [0m
|
|
6
|
+
[32m@openmrs/esm-utils:test: [0mTest Suites: 2 passed, 2 total
|
|
7
|
+
[32m@openmrs/esm-utils:test: [0mTests: 22 passed, 22 total
|
|
8
|
+
[32m@openmrs/esm-utils:test: [0mSnapshots: 0 total
|
|
9
|
+
[32m@openmrs/esm-utils:test: [0mTime: 5.794 s
|
|
10
|
+
[32m@openmrs/esm-utils:test: [0mRan all test suites.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
1
|
+
[32m@openmrs/esm-utils:typescript: [0mcache hit, replaying output [2m7a618d75536aa1cc[0m
|
|
2
|
+
[32m@openmrs/esm-utils:typescript: [0m$ tsc
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @module @category Utility */
|
|
2
|
+
/**
|
|
3
|
+
* Gets the number of days in the year of the given date.
|
|
4
|
+
* @param date The date to compute the days within the year.
|
|
5
|
+
* @returns The number of days.
|
|
6
|
+
*/
|
|
7
|
+
export declare function daysIntoYear(date: Date): number;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if two dates are representing the same day.
|
|
10
|
+
* @param firstDate The first date.
|
|
11
|
+
* @param secondDate The second date.
|
|
12
|
+
* @returns True if both are located on the same day.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isSameDay(firstDate: Date, secondDate: Date): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Gets a human readable age represention of the provided date string.
|
|
17
|
+
* @param dateString The stringified date.
|
|
18
|
+
* @returns A human-readable string version of the age.
|
|
19
|
+
*/
|
|
20
|
+
export declare function age(dateString: string): string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @category Date and Time
|
|
4
|
+
*/
|
|
5
|
+
import { i18n } from "i18next";
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
i18next: i18n;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare type DateInput = string | number | Date;
|
|
12
|
+
/**
|
|
13
|
+
* This function is STRICT on checking whether a date string is the openmrs format.
|
|
14
|
+
* The format should be YYYY-MM-DDTHH:mm:ss.SSSZZ
|
|
15
|
+
*/
|
|
16
|
+
export declare function isOmrsDateStrict(omrsPayloadString: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param date Checks if the provided date is today.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isOmrsDateToday(date: DateInput): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Converts the object to a date object if it is a valid ISO date time string.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toDateObjectStrict(omrsDateString: string): Date | null;
|
|
26
|
+
/**
|
|
27
|
+
* Formats the input as a date time string using the format "YYYY-MM-DDTHH:mm:ss.SSSZZ".
|
|
28
|
+
*/
|
|
29
|
+
export declare function toOmrsIsoString(date: DateInput, toUTC?: boolean): string;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use `formatTime`
|
|
32
|
+
* Formats the input as a time string using the format "HH:mm".
|
|
33
|
+
*/
|
|
34
|
+
export declare function toOmrsTimeString24(date: DateInput): string;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use `formatTime`
|
|
37
|
+
* Formats the input as a time string using the format "HH:mm A".
|
|
38
|
+
*/
|
|
39
|
+
export declare function toOmrsTimeString(date: DateInput): string;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated use `formatDate(date, "wide")`
|
|
42
|
+
* Formats the input as a date string using the format "DD - MMM - YYYY".
|
|
43
|
+
*/
|
|
44
|
+
export declare function toOmrsDayDateFormat(date: DateInput): string;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use `formatDate(date, "no year")`
|
|
47
|
+
* Formats the input as a date string using the format "DD-MMM".
|
|
48
|
+
*/
|
|
49
|
+
export declare function toOmrsYearlessDateFormat(date: DateInput): string;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated use `formatDate(date)`
|
|
52
|
+
* Formats the input as a date string. By default the format "YYYY-MMM-DD" is used.
|
|
53
|
+
*/
|
|
54
|
+
export declare function toOmrsDateFormat(date: DateInput, format?: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Utility function to parse an arbitrary string into a date.
|
|
57
|
+
* Uses `dayjs(dateString)`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseDate(dateString: string): Date;
|
|
60
|
+
export declare type FormatDateMode = "standard" | "wide";
|
|
61
|
+
export declare type FormatDateOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* - `standard`: "03 Feb 2022"
|
|
64
|
+
* - `wide`: "03 — Feb — 2022"
|
|
65
|
+
*/
|
|
66
|
+
mode: FormatDateMode;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the time should be included in the output always (`true`),
|
|
69
|
+
* never (`false`), or only when the input date is today (`for today`).
|
|
70
|
+
*/
|
|
71
|
+
time: true | false | "for today";
|
|
72
|
+
/** Whether to include the day number */
|
|
73
|
+
day: boolean;
|
|
74
|
+
/** Whether to include the year */
|
|
75
|
+
year: boolean;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Formats the input date according to the current locale and the
|
|
79
|
+
* given options.
|
|
80
|
+
*
|
|
81
|
+
* Default options:
|
|
82
|
+
* - mode: "standard",
|
|
83
|
+
* - time: "for today",
|
|
84
|
+
* - day: true,
|
|
85
|
+
* - year: true
|
|
86
|
+
*
|
|
87
|
+
* If the date is today then "Today" is produced (in the locale language).
|
|
88
|
+
*
|
|
89
|
+
* When time is included, it is appended with a comma and a space. This
|
|
90
|
+
* agrees with the output of `Date.prototype.toLocaleString` for *most*
|
|
91
|
+
* locales.
|
|
92
|
+
*
|
|
93
|
+
* TODO: Shouldn't throw on null input
|
|
94
|
+
*/
|
|
95
|
+
export declare function formatDate(date: Date, options?: Partial<FormatDateOptions>): string;
|
|
96
|
+
/**
|
|
97
|
+
* Formats the input as a time, according to the current locale.
|
|
98
|
+
* 12-hour or 24-hour clock depends on locale.
|
|
99
|
+
*/
|
|
100
|
+
export declare function formatTime(date: Date): string;
|
|
101
|
+
/**
|
|
102
|
+
* Formats the input into a string showing the date and time, according
|
|
103
|
+
* to the current locale. The `mode` parameter is as described for
|
|
104
|
+
* `formatDate`.
|
|
105
|
+
*
|
|
106
|
+
* This is created by concatenating the results of `formatDate`
|
|
107
|
+
* and `formatTime` with a comma and space. This agrees with the
|
|
108
|
+
* output of `Date.prototype.toLocaleString` for *most* locales.
|
|
109
|
+
*/
|
|
110
|
+
export declare function formatDatetime(date: Date, options?: Partial<Omit<FormatDateOptions, "time">>): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|