yummies 3.3.0 → 3.4.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/date-time.d.ts +3 -2
- package/date-time.d.ts.map +1 -1
- package/date-time.js +5 -5
- package/package.json +1 -1
package/date-time.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Dayjs, ManipulateType } from 'dayjs';
|
|
2
2
|
import { Maybe } from './utils/types.js';
|
|
3
3
|
import 'dayjs/locale/ru.js';
|
|
4
|
-
export
|
|
4
|
+
export type RawDateToFormat = Date | string | number | Dayjs;
|
|
5
|
+
export declare const formatDate: (value: Maybe<RawDateToFormat>, settings?: Maybe<{
|
|
5
6
|
format?: "human" | "full" | "short" | "day" | "day-only" | "date" | "month" | "spent-time" | "time" | "time-short";
|
|
6
7
|
pattern?: string;
|
|
7
8
|
asTime?: boolean;
|
|
@@ -14,7 +15,7 @@ export declare const dayTimeDuration: (timeInMs: number) => {
|
|
|
14
15
|
milliseconds: number;
|
|
15
16
|
};
|
|
16
17
|
type DateChangeParam = [amount: number, unit?: Maybe<ManipulateType>];
|
|
17
|
-
export declare const changeDate: (date: Maybe<
|
|
18
|
+
export declare const changeDate: (date: Maybe<RawDateToFormat>, ...args: [...DateChangeParam, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>]) => Date;
|
|
18
19
|
export declare const timeDuration: (timeInMs: number) => {
|
|
19
20
|
hours: number;
|
|
20
21
|
milliseconds: number;
|
package/date-time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAOrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,oBAA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AI,EACX,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAAC;AACV,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC"}
|
package/date-time.js
CHANGED
|
@@ -16,19 +16,19 @@ const toLibFormat = function (value, asTime) {
|
|
|
16
16
|
}
|
|
17
17
|
return dayjs(value);
|
|
18
18
|
}
|
|
19
|
-
else if (typeGuard.isString(value)) {
|
|
20
|
-
return dayjs(value);
|
|
21
|
-
}
|
|
22
19
|
else if (dayjs.isDayjs(value)) {
|
|
23
20
|
return value;
|
|
24
21
|
}
|
|
22
|
+
else {
|
|
23
|
+
return dayjs(value);
|
|
24
|
+
}
|
|
25
25
|
};
|
|
26
26
|
export const formatDate = function (value, settings) {
|
|
27
27
|
const dateFormat = settings?.format;
|
|
28
28
|
const datePattern = settings?.pattern;
|
|
29
29
|
const asTime = settings?.asTime;
|
|
30
30
|
value = toLibFormat(value, asTime);
|
|
31
|
-
if (typeGuard.isUndefined(value)) {
|
|
31
|
+
if (typeGuard.isUndefined(value) || !value.isValid()) {
|
|
32
32
|
return NO_VALUE;
|
|
33
33
|
}
|
|
34
34
|
if (datePattern) {
|
|
@@ -84,7 +84,7 @@ export const dayTimeDuration = (timeInMs) => {
|
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
export const changeDate = (date, ...args) => {
|
|
87
|
-
let wrappedDate =
|
|
87
|
+
let wrappedDate = toLibFormat(date);
|
|
88
88
|
for (let i = 0; i < args.length; i += 2) {
|
|
89
89
|
const amount = args[i];
|
|
90
90
|
const unit = args[i + 1];
|