date-and-time 2.2.1 → 2.3.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.
Files changed (52) hide show
  1. package/PLUGINS.md +22 -22
  2. package/README.md +81 -80
  3. package/date-and-time.d.ts +304 -0
  4. package/date-and-time.js +73 -72
  5. package/esm/date-and-time.es.js +73 -72
  6. package/esm/date-and-time.mjs +73 -72
  7. package/esm/plugin/timezone.es.js +1 -1
  8. package/esm/plugin/timezone.mjs +1 -1
  9. package/locale/ar.d.ts +1 -0
  10. package/locale/az.d.ts +1 -0
  11. package/locale/bn.d.ts +1 -0
  12. package/locale/cs.d.ts +1 -0
  13. package/locale/de.d.ts +1 -0
  14. package/locale/dk.d.ts +1 -0
  15. package/locale/el.d.ts +1 -0
  16. package/locale/en.d.ts +1 -0
  17. package/locale/es.d.ts +1 -0
  18. package/locale/fa.d.ts +1 -0
  19. package/locale/fr.d.ts +1 -0
  20. package/locale/hi.d.ts +1 -0
  21. package/locale/hu.d.ts +1 -0
  22. package/locale/id.d.ts +1 -0
  23. package/locale/it.d.ts +1 -0
  24. package/locale/ja.d.ts +1 -0
  25. package/locale/jv.d.ts +1 -0
  26. package/locale/ko.d.ts +1 -0
  27. package/locale/my.d.ts +1 -0
  28. package/locale/nl.d.ts +1 -0
  29. package/locale/pa-in.d.ts +1 -0
  30. package/locale/pl.d.ts +1 -0
  31. package/locale/pt.d.ts +1 -0
  32. package/locale/ro.d.ts +1 -0
  33. package/locale/ru.d.ts +1 -0
  34. package/locale/rw.d.ts +1 -0
  35. package/locale/sr.d.ts +1 -0
  36. package/locale/sv.d.ts +1 -0
  37. package/locale/th.d.ts +1 -0
  38. package/locale/tr.d.ts +1 -0
  39. package/locale/uk.d.ts +1 -0
  40. package/locale/uz.d.ts +1 -0
  41. package/locale/vi.d.ts +1 -0
  42. package/locale/zh-cn.d.ts +1 -0
  43. package/locale/zh-tw.d.ts +1 -0
  44. package/package.json +6 -3
  45. package/plugin/day-of-week.d.ts +1 -0
  46. package/plugin/meridiem.d.ts +1 -0
  47. package/plugin/microsecond.d.ts +1 -0
  48. package/plugin/ordinal.d.ts +1 -0
  49. package/plugin/timespan.d.ts +24 -0
  50. package/plugin/timezone.d.ts +79 -0
  51. package/plugin/timezone.js +1 -1
  52. package/plugin/two-digit-year.d.ts +1 -0
package/locale/pl.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/pt.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/ro.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/ru.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/rw.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/sr.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/sv.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/th.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/tr.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/uk.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/uz.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/vi.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "date-and-time",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "A Minimalist DateTime utility for Node.js and the browser",
5
5
  "main": "date-and-time.js",
6
6
  "module": "esm/date-and-time.es.js",
7
+ "types": "date-and-time.d.ts",
7
8
  "unpkg": "date-and-time.min.js",
8
9
  "exports": {
9
10
  ".": {
@@ -24,7 +25,8 @@
24
25
  },
25
26
  "scripts": {
26
27
  "build": "rollup --config rollup.config.js",
27
- "test": "./test.sh"
28
+ "test": "./test.sh",
29
+ "test:ts": "tsd ./test/ts"
28
30
  },
29
31
  "repository": {
30
32
  "type": "git",
@@ -48,6 +50,7 @@
48
50
  "expect.js": "^0.3.1",
49
51
  "mocha": "^9.2.1",
50
52
  "mocha-headless-chrome": "^4.0.0",
51
- "rollup": "^2.68.0"
53
+ "rollup": "^2.70.0",
54
+ "tsd": "^0.19.1"
52
55
  }
53
56
  }
@@ -0,0 +1 @@
1
+ export default function (date: unknown, localized_date?: unknown): string;
@@ -0,0 +1 @@
1
+ export default function (date: unknown, localized_date?: unknown): string;
@@ -0,0 +1 @@
1
+ export default function (date: unknown, localized_date?: unknown): string;
@@ -0,0 +1 @@
1
+ export default function (date: unknown, localized_date?: unknown): string;
@@ -0,0 +1,24 @@
1
+ declare module '../date-and-time' {
2
+ export type TimeSpanResult = {
3
+ /** Returns the result value in milliseconds. */
4
+ toMilliseconds: (formatString: string) => string,
5
+ /** Returns the result value in seconds. */
6
+ toSeconds: (formatString: string) => string,
7
+ /** Returns the result value in minutes. */
8
+ toMinutes: (formatString: string) => string,
9
+ /** Returns the result value in hours. */
10
+ toHours: (formatString: string) => string,
11
+ /** Returns the result value in days. */
12
+ toDays: (formatString: string) => string
13
+ };
14
+
15
+ /**
16
+ * Subtracting two dates (date1 - date2)
17
+ * @param date1 - A Date object
18
+ * @param date2 - A Date object
19
+ * @returns The result object of subtracting date2 from date1
20
+ */
21
+ export function timeSpan(date1: Date, date2: Date): TimeSpanResult;
22
+ }
23
+
24
+ export default function (date: unknown, localized_date?: unknown): string;
@@ -0,0 +1,79 @@
1
+ declare module '../date-and-time' {
2
+ /**
3
+ * Formatting date and time objects using time zone names (Date -> String)
4
+ * @param dateObj - A Date object
5
+ * @param formatString - A format string
6
+ * @param [timeZone] - Output as this time zone
7
+ * @returns A formatted string
8
+ */
9
+ export function formatTZ(dateObj: Date, formatString: string, timeZone?: string): string;
10
+
11
+ /**
12
+ * Formatting date and time objects using time zone names (Date -> String)
13
+ * @param dateObj - A Date object
14
+ * @param compiledObj - A compiled object of format string
15
+ * @param [timeZone] - Output as this time zone
16
+ * @returns A formatted string
17
+ */
18
+ export function formatTZ(dateObj: Date, compiledObj: string[], timeZone?: string): string;
19
+
20
+ /**
21
+ * Parsing date and time strings using time zone names (String -> Date)
22
+ * @param dateString - A date and time string
23
+ * @param formatString - A format string
24
+ * @param [timeZone] - Input as this time zone
25
+ * @returns A Date object
26
+ */
27
+ export function parseTZ(dateString: string, formatString: string, timeZone?: string): Date;
28
+
29
+ /**
30
+ * Parsing date and time strings using time zone names (String -> Date)
31
+ * @param dateString - A date and time string
32
+ * @param compiledObj - A compiled object of format string
33
+ * @param [timeZone] - Input as this time zone
34
+ * @returns A Date object
35
+ */
36
+ export function parseTZ(dateString: string, compiledObj: string[], timeZone?: string): Date;
37
+
38
+ /**
39
+ * Format transformation of date and time strings using time zone names (String -> String)
40
+ * @param dateString - A date and time string
41
+ * @param formatString1 - A format string before transformation
42
+ * @param formatString2 - A format string after transformation
43
+ * @param [timeZone] - Output as this time zone
44
+ * @returns A formatted string
45
+ */
46
+ export function transformTZ(dateString: string, formatString1: string, formatString2: string, timeZone?: string): string;
47
+
48
+ /**
49
+ * Format transformation of date and time strings using time zone names (String -> String)
50
+ * @param dateString - A date and time string
51
+ * @param formatString - A format string before transformation
52
+ * @param compiledObj - A compiled object of format string after transformation
53
+ * @param [timeZone] - Output as this time zone
54
+ * @returns A formatted string
55
+ */
56
+ export function transformTZ(dateString: string, formatString: string, compiledObj: string[], timeZone?: string): string;
57
+
58
+ /**
59
+ * Format transformation of date and time strings using time zone names (String -> String)
60
+ * @param dateString - A date and time string
61
+ * @param compiledObj - A compiled object of format string before transformation
62
+ * @param formatString - A format string after transformation
63
+ * @param [timeZone] - Output as this time zone
64
+ * @returns A formatted string
65
+ */
66
+ export function transformTZ(dateString: string, compiledObj: string[], formatString: string, timeZone?: string): string;
67
+
68
+ /**
69
+ * Format transformation of date and time strings using time zone names (String -> String)
70
+ * @param dateString - A date and time string
71
+ * @param compiledObj1 - A compiled object of format string before transformation
72
+ * @param compiledObj2 - A compiled object of format string after transformation
73
+ * @param [timeZone] - Output as this time zone
74
+ * @returns A formatted string
75
+ */
76
+ export function transformTZ(dateString: string, compiledObj1: string[], compiledObj2: string[], timeZone?: string): string;
77
+ }
78
+
79
+ export default function (date: unknown, localized_date?: unknown): string;
@@ -60,7 +60,7 @@
60
60
  return d;
61
61
  }
62
62
  }
63
- return NaN;
63
+ return new Date(NaN);
64
64
  };
65
65
  var transformTZ = function (dateString, arg1, arg2, timeZone) {
66
66
  return formatTZ(localized_date.parse(dateString, arg1), arg2, timeZone);
@@ -0,0 +1 @@
1
+ export default function (date: unknown, localized_date?: unknown): string;