@alextheman/utility 1.7.3 → 1.8.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/index.cjs +11 -8
- package/dist/index.js +11 -8
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -72,16 +72,19 @@ var add_days_to_date_default = addDaysToDate;
|
|
|
72
72
|
|
|
73
73
|
// src/format-date-and-time.ts
|
|
74
74
|
function formatDateAndTime(inputDate) {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const yesterday = add_days_to_date_default(/* @__PURE__ */ new Date(), -1);
|
|
76
|
+
const today = /* @__PURE__ */ new Date();
|
|
77
|
+
const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
|
|
78
|
+
if (inputDate.getDate() === yesterday.getDate() && inputDate.getMonth() === yesterday.getMonth() && inputDate.getFullYear() === yesterday.getFullYear()) {
|
|
79
|
+
return `Yesterday at ${inputTime}`;
|
|
79
80
|
}
|
|
80
|
-
if (inputDate.
|
|
81
|
-
return `Today at ${
|
|
81
|
+
if (inputDate.getDate() === today.getDate() && inputDate.getMonth() === yesterday.getMonth() && inputDate.getFullYear() === today.getFullYear()) {
|
|
82
|
+
return `Today at ${inputTime}`;
|
|
82
83
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
84
|
+
const formattedInputDay = inputDate.getDate().toString().padStart(2, "0");
|
|
85
|
+
const formattedInputMonth = (inputDate.getMonth() + 1).toString().padStart(2, "0");
|
|
86
|
+
const formattedInputYear = inputDate.getFullYear().toString().padStart(2, "0");
|
|
87
|
+
return `${formattedInputDay}/${formattedInputMonth}/${formattedInputYear}, ${inputTime}`;
|
|
85
88
|
}
|
|
86
89
|
var format_date_and_time_default = formatDateAndTime;
|
|
87
90
|
|
package/dist/index.js
CHANGED
|
@@ -39,16 +39,19 @@ var add_days_to_date_default = addDaysToDate;
|
|
|
39
39
|
|
|
40
40
|
// src/format-date-and-time.ts
|
|
41
41
|
function formatDateAndTime(inputDate) {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const yesterday = add_days_to_date_default(/* @__PURE__ */ new Date(), -1);
|
|
43
|
+
const today = /* @__PURE__ */ new Date();
|
|
44
|
+
const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
|
|
45
|
+
if (inputDate.getDate() === yesterday.getDate() && inputDate.getMonth() === yesterday.getMonth() && inputDate.getFullYear() === yesterday.getFullYear()) {
|
|
46
|
+
return `Yesterday at ${inputTime}`;
|
|
46
47
|
}
|
|
47
|
-
if (inputDate.
|
|
48
|
-
return `Today at ${
|
|
48
|
+
if (inputDate.getDate() === today.getDate() && inputDate.getMonth() === yesterday.getMonth() && inputDate.getFullYear() === today.getFullYear()) {
|
|
49
|
+
return `Today at ${inputTime}`;
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
51
|
+
const formattedInputDay = inputDate.getDate().toString().padStart(2, "0");
|
|
52
|
+
const formattedInputMonth = (inputDate.getMonth() + 1).toString().padStart(2, "0");
|
|
53
|
+
const formattedInputYear = inputDate.getFullYear().toString().padStart(2, "0");
|
|
54
|
+
return `${formattedInputDay}/${formattedInputMonth}/${formattedInputYear}, ${inputTime}`;
|
|
52
55
|
}
|
|
53
56
|
var format_date_and_time_default = formatDateAndTime;
|
|
54
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "
|
|
13
|
-
"test-watch": "
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test-watch": "vitest",
|
|
14
14
|
"format": "prettier --write --parser typescript 'src/**/*.ts' 'tests/**/*.test.ts' && ESLINT_MODE=fix eslint --fix 'src/**/*.ts' 'tests/**/*.ts'",
|
|
15
15
|
"lint": "ESLINT_MODE=lint eslint 'src/**/*.ts' 'tests/**/*.ts' && prettier --check --parser typescript 'src/**/*.ts' 'tests/**/*.ts'",
|
|
16
16
|
"prepare": "husky",
|