yummies 3.0.12 → 3.0.13

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 CHANGED
@@ -6,6 +6,7 @@ export declare const formatDate: (value: Maybe<string | number | Dayjs>, setting
6
6
  pattern?: string;
7
7
  asTime?: boolean;
8
8
  }>) => string;
9
+ export declare const getDatesDuration: (dateA: Date, dateB: Date) => string;
9
10
  export declare const timeDuration: (timeInMs: number) => {
10
11
  hours: number;
11
12
  minutes: number;
@@ -1 +1 @@
1
- {"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAKrC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,iBAAiB,CAAC;AAwBzB,eAAO,MAAM,UAAU,UACd,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,aAC1B,KAAK,CAAC;IACf,MAAM,CAAC,EACH,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,YAAY,GACZ,MAAM,GACN,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,WA6CH,CAAC;AAEF,eAAO,MAAM,YAAY,aAAc,MAAM;;;;CAQ5C,CAAC"}
1
+ {"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAKrC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,iBAAiB,CAAC;AAwBzB,eAAO,MAAM,UAAU,UACd,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,aAC1B,KAAK,CAAC;IACf,MAAM,CAAC,EACH,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,YAAY,GACZ,MAAM,GACN,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,WA6CH,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,IAAI,SAAS,IAAI,WAoBxD,CAAC;AAEF,eAAO,MAAM,YAAY,aAAc,MAAM;;;;CAQ5C,CAAC"}
package/date-time.js CHANGED
@@ -62,6 +62,30 @@ export const formatDate = function (value, settings) {
62
62
  }
63
63
  }
64
64
  };
65
+ export const getDatesDuration = (dateA, dateB) => {
66
+ const startedDate = dayjs(dateA);
67
+ const endedDate = dayjs(dateB);
68
+ const diff = endedDate.diff(startedDate, 'ms');
69
+ const duration = dayjs.duration(diff);
70
+ if (duration.asSeconds() < 1) {
71
+ return duration.format('SSS[ мс]');
72
+ }
73
+ else if (duration.asMinutes() < 1) {
74
+ return duration.format('s[ сек]');
75
+ }
76
+ else if (duration.asHours() < 1) {
77
+ return duration.format('m[ мин] s[ сек]');
78
+ }
79
+ else if (duration.asDays() < 1) {
80
+ return duration.format('h[ ч] m[ мин] s[ сек]');
81
+ }
82
+ else if (duration.asMonths() < 1) {
83
+ return duration.format('D[ д] H[ ч] m[ мин] s[ сек]');
84
+ }
85
+ else {
86
+ return duration.format('M[ мес] D[ д] H[ ч] m[ мин] s[ сек]');
87
+ }
88
+ };
65
89
  export const timeDuration = (timeInMs) => {
66
90
  const duration = dayjs.duration(timeInMs);
67
91
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yummies",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "keywords": [],
5
5
  "author": "js2me",
6
6
  "license": "MIT",