@mll-lab/js-utils 1.3.3 → 2.1.0
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/dist/date.d.ts +20 -20
- package/dist/index.common.js +52 -30
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +52 -30
- package/dist/index.js.map +1 -1
- package/dist/round.d.ts +6 -0
- package/dist/round.test.d.ts +1 -0
- package/package.json +5 -2
package/dist/date.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare const GERMAN_DATE_FORMAT: string;
|
|
3
|
-
/**
|
|
4
|
-
* Reverse order of standard german format to sort correctly.
|
|
5
|
-
*/
|
|
6
|
-
export declare const ISO_GERMAN_DATE_FORMAT: string;
|
|
7
|
-
export declare const GERMAN_DATE_TIME_FORMAT: string;
|
|
8
|
-
export declare const ISO_DATE_FORMAT: string;
|
|
9
|
-
export declare const ISO_DATE_TIME_FORMAT: string;
|
|
10
|
-
export declare const SECONDLESS_DATE_TIME_FORMAT: string;
|
|
11
|
-
export declare const MINIMAL_VALID_DATE: Date;
|
|
1
|
+
export declare function isToday(date: Date | string | number): boolean;
|
|
12
2
|
export declare function parseDate(value: string, formatString: string): Date | null;
|
|
3
|
+
export declare function parseGermanDateFlexible(value: string): Date | null;
|
|
4
|
+
export declare const GERMAN_DATE_FORMAT: string;
|
|
13
5
|
export declare function parseGermanDate(value: string): Date | null;
|
|
6
|
+
export declare function formatGerman(date: Date | string | number): string;
|
|
7
|
+
export declare const ISO_DATE_FORMAT: string;
|
|
14
8
|
export declare function parseIsoDate(value: string): Date | null;
|
|
15
|
-
export declare function
|
|
9
|
+
export declare function formatIsoDate(date: Date | string | number): string;
|
|
10
|
+
export declare const GERMAN_DOTLESS_DATE_FORMAT: string;
|
|
16
11
|
export declare function parseGermanDotlessDate(value: string): Date | null;
|
|
17
|
-
export declare function
|
|
18
|
-
export declare
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare
|
|
12
|
+
export declare function formatGermanDotlessDate(date: Date | string | number): string;
|
|
13
|
+
export declare const SECONDLESS_DATE_TIME_FORMAT: string;
|
|
14
|
+
export declare function parseSecondlessDateTime(value: string): Date | null;
|
|
15
|
+
export declare function formatSecondlessDateTime(date: Date | string | number): string;
|
|
16
|
+
export declare const GERMAN_DATE_TIME_FORMAT: string;
|
|
17
|
+
export declare function parseGermanDateTime(value: string): Date | null;
|
|
18
|
+
export declare function formatGermanDateTime(date: Date | string | number): string;
|
|
19
|
+
export declare const ISO_DATE_TIME_FORMAT: string;
|
|
20
|
+
export declare function parseIsoDateTime(value: string): Date | null;
|
|
21
|
+
export declare function formatIsoDateTime(date: Date | string | number): string;
|
|
22
|
+
export declare const DOTLESS_DATE_FORMAT: string;
|
|
23
|
+
export declare function parseDotlessDate(value: string): Date | null;
|
|
24
|
+
export declare function formatDotlessDate(date: Date | string | number): string;
|
package/dist/index.common.js
CHANGED
|
@@ -15004,56 +15004,64 @@ var de = createCommonjsModule(function (module, exports) {
|
|
|
15004
15004
|
});
|
|
15005
15005
|
var de$1 = /*@__PURE__*/getDefaultExportFromCjs(de);
|
|
15006
15006
|
|
|
15007
|
-
|
|
15008
|
-
|
|
15009
|
-
|
|
15010
|
-
* Reverse order of standard german format to sort correctly.
|
|
15011
|
-
*/
|
|
15012
|
-
const ISO_GERMAN_DATE_FORMAT = 'y.MM.dd';
|
|
15013
|
-
const GERMAN_DATE_TIME_FORMAT = 'dd.MM.y HH:mm';
|
|
15014
|
-
const ISO_DATE_FORMAT = 'y-MM-dd';
|
|
15015
|
-
const ISO_DATE_TIME_FORMAT = 'y-MM-dd HH:mm:ss';
|
|
15016
|
-
const SECONDLESS_DATE_TIME_FORMAT = 'y-MM-dd HH:mm';
|
|
15017
|
-
const MINIMAL_VALID_DATE = new Date(1900, 0, 1);
|
|
15007
|
+
function isToday(date) {
|
|
15008
|
+
return differenceInCalendarDays(new Date(), date) === 0;
|
|
15009
|
+
}
|
|
15018
15010
|
function parseDate(value, formatString) {
|
|
15019
15011
|
const parsedDate = parse(value, formatString, new Date());
|
|
15020
15012
|
return isValid(parsedDate) ? parsedDate : null;
|
|
15021
15013
|
}
|
|
15014
|
+
function parseGermanDateFlexible(value) {
|
|
15015
|
+
return parseGermanDotlessDate(value) || parseGermanDate(value);
|
|
15016
|
+
}
|
|
15017
|
+
const GERMAN_DATE_FORMAT = 'dd.MM.y';
|
|
15022
15018
|
function parseGermanDate(value) {
|
|
15023
15019
|
return parseDate(value, GERMAN_DATE_FORMAT);
|
|
15024
15020
|
}
|
|
15021
|
+
function formatGerman(date) {
|
|
15022
|
+
return format(date, GERMAN_DATE_FORMAT, { locale: de$1 });
|
|
15023
|
+
}
|
|
15024
|
+
const ISO_DATE_FORMAT = 'y-MM-dd';
|
|
15025
15025
|
function parseIsoDate(value) {
|
|
15026
15026
|
return parseDate(value, ISO_DATE_FORMAT);
|
|
15027
15027
|
}
|
|
15028
|
-
function
|
|
15029
|
-
return
|
|
15028
|
+
function formatIsoDate(date) {
|
|
15029
|
+
return format(date, ISO_DATE_FORMAT, { locale: de$1 });
|
|
15030
15030
|
}
|
|
15031
|
+
const GERMAN_DOTLESS_DATE_FORMAT = 'ddMMy';
|
|
15031
15032
|
function parseGermanDotlessDate(value) {
|
|
15032
15033
|
return parseDate(value, GERMAN_DOTLESS_DATE_FORMAT);
|
|
15033
15034
|
}
|
|
15034
|
-
function
|
|
15035
|
-
return
|
|
15035
|
+
function formatGermanDotlessDate(date) {
|
|
15036
|
+
return format(date, GERMAN_DOTLESS_DATE_FORMAT, { locale: de$1 });
|
|
15036
15037
|
}
|
|
15037
|
-
|
|
15038
|
-
|
|
15038
|
+
const SECONDLESS_DATE_TIME_FORMAT = 'y-MM-dd HH:mm';
|
|
15039
|
+
function parseSecondlessDateTime(value) {
|
|
15040
|
+
return parseDate(value, SECONDLESS_DATE_TIME_FORMAT);
|
|
15039
15041
|
}
|
|
15040
|
-
function
|
|
15041
|
-
return format(date,
|
|
15042
|
+
function formatSecondlessDateTime(date) {
|
|
15043
|
+
return format(date, SECONDLESS_DATE_TIME_FORMAT, { locale: de$1 });
|
|
15044
|
+
}
|
|
15045
|
+
const GERMAN_DATE_TIME_FORMAT = 'dd.MM.y HH:mm';
|
|
15046
|
+
function parseGermanDateTime(value) {
|
|
15047
|
+
return parseDate(value, GERMAN_DATE_TIME_FORMAT);
|
|
15042
15048
|
}
|
|
15043
15049
|
function formatGermanDateTime(date) {
|
|
15044
15050
|
return format(date, GERMAN_DATE_TIME_FORMAT, { locale: de$1 });
|
|
15045
15051
|
}
|
|
15046
|
-
|
|
15047
|
-
|
|
15052
|
+
const ISO_DATE_TIME_FORMAT = 'y-MM-dd HH:mm:ss';
|
|
15053
|
+
function parseIsoDateTime(value) {
|
|
15054
|
+
return parseDate(value, ISO_DATE_TIME_FORMAT);
|
|
15048
15055
|
}
|
|
15049
|
-
function
|
|
15050
|
-
return format(
|
|
15056
|
+
function formatIsoDateTime(date) {
|
|
15057
|
+
return format(date, ISO_DATE_TIME_FORMAT, { locale: de$1 });
|
|
15051
15058
|
}
|
|
15052
|
-
|
|
15053
|
-
|
|
15059
|
+
const DOTLESS_DATE_FORMAT = 'yMMdd';
|
|
15060
|
+
function parseDotlessDate(value) {
|
|
15061
|
+
return parseDate(value, DOTLESS_DATE_FORMAT);
|
|
15054
15062
|
}
|
|
15055
|
-
function
|
|
15056
|
-
return
|
|
15063
|
+
function formatDotlessDate(date) {
|
|
15064
|
+
return format(date, DOTLESS_DATE_FORMAT, { locale: de$1 });
|
|
15057
15065
|
}
|
|
15058
15066
|
|
|
15059
15067
|
function pluralize(amount, singular, plural) {
|
|
@@ -15096,6 +15104,17 @@ const isWord = (value) => isString(value) && /^[\w-]+$/.test(value);
|
|
|
15096
15104
|
const isLabId = (value) => isString(value) && /^\d{2}-\d{6}$/.test(value);
|
|
15097
15105
|
const isRackBarcode = (value) => isString(value) && /^[A-Z]{2}\d{8}$/.test(value);
|
|
15098
15106
|
|
|
15107
|
+
/**
|
|
15108
|
+
* Round a number to a given number of decimal places.
|
|
15109
|
+
*
|
|
15110
|
+
* https://gist.github.com/djD-REK/2e347f5532bb22310daf450f03ec6ad8
|
|
15111
|
+
*/
|
|
15112
|
+
function round(number, decimalPlaces) {
|
|
15113
|
+
const factorOfTen = Math.pow(10, decimalPlaces);
|
|
15114
|
+
return Math.round(number * factorOfTen) / factorOfTen;
|
|
15115
|
+
}
|
|
15116
|
+
|
|
15117
|
+
exports.DOTLESS_DATE_FORMAT = DOTLESS_DATE_FORMAT;
|
|
15099
15118
|
exports.EMAIL_REGEX = EMAIL_REGEX;
|
|
15100
15119
|
exports.EMPTY_ARRAY = EMPTY_ARRAY;
|
|
15101
15120
|
exports.GERMAN_DATE_FORMAT = GERMAN_DATE_FORMAT;
|
|
@@ -15103,15 +15122,14 @@ exports.GERMAN_DATE_TIME_FORMAT = GERMAN_DATE_TIME_FORMAT;
|
|
|
15103
15122
|
exports.GERMAN_DOTLESS_DATE_FORMAT = GERMAN_DOTLESS_DATE_FORMAT;
|
|
15104
15123
|
exports.ISO_DATE_FORMAT = ISO_DATE_FORMAT;
|
|
15105
15124
|
exports.ISO_DATE_TIME_FORMAT = ISO_DATE_TIME_FORMAT;
|
|
15106
|
-
exports.ISO_GERMAN_DATE_FORMAT = ISO_GERMAN_DATE_FORMAT;
|
|
15107
|
-
exports.MINIMAL_VALID_DATE = MINIMAL_VALID_DATE;
|
|
15108
15125
|
exports.SECONDLESS_DATE_TIME_FORMAT = SECONDLESS_DATE_TIME_FORMAT;
|
|
15109
15126
|
exports.containSameValues = containSameValues;
|
|
15127
|
+
exports.formatDotlessDate = formatDotlessDate;
|
|
15110
15128
|
exports.formatGerman = formatGerman;
|
|
15111
15129
|
exports.formatGermanDateTime = formatGermanDateTime;
|
|
15130
|
+
exports.formatGermanDotlessDate = formatGermanDotlessDate;
|
|
15112
15131
|
exports.formatIsoDate = formatIsoDate;
|
|
15113
15132
|
exports.formatIsoDateTime = formatIsoDateTime;
|
|
15114
|
-
exports.formatIsoGerman = formatIsoGerman;
|
|
15115
15133
|
exports.formatSecondlessDateTime = formatSecondlessDateTime;
|
|
15116
15134
|
exports.insertIf = insertIf;
|
|
15117
15135
|
exports.isAlphanumeric = isAlphanumeric;
|
|
@@ -15125,11 +15143,15 @@ exports.isToday = isToday;
|
|
|
15125
15143
|
exports.isURL = isURL;
|
|
15126
15144
|
exports.isWord = isWord;
|
|
15127
15145
|
exports.parseDate = parseDate;
|
|
15146
|
+
exports.parseDotlessDate = parseDotlessDate;
|
|
15128
15147
|
exports.parseGermanDate = parseGermanDate;
|
|
15129
15148
|
exports.parseGermanDateFlexible = parseGermanDateFlexible;
|
|
15149
|
+
exports.parseGermanDateTime = parseGermanDateTime;
|
|
15130
15150
|
exports.parseGermanDotlessDate = parseGermanDotlessDate;
|
|
15131
15151
|
exports.parseIsoDate = parseIsoDate;
|
|
15152
|
+
exports.parseIsoDateTime = parseIsoDateTime;
|
|
15132
15153
|
exports.parseSecondlessDateTime = parseSecondlessDateTime;
|
|
15133
15154
|
exports.pluralize = pluralize;
|
|
15155
|
+
exports.round = round;
|
|
15134
15156
|
exports.withoutIndex = withoutIndex;
|
|
15135
15157
|
//# sourceMappingURL=index.common.js.map
|