clockey 1.0.0 → 1.0.2
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/README.md +159 -2
- package/dist/index.d.mts +194 -0
- package/dist/index.d.ts +194 -0
- package/dist/index.js +434 -0
- package/dist/index.mjs +377 -0
- package/package.json +4 -1
- package/src/core/date.ts +0 -91
- package/src/core/time.ts +0 -80
- package/src/index.ts +0 -2
- package/src/response/dateResponse.ts +0 -105
- package/src/response/timeResponse.ts +0 -143
- package/src/types/date.d.ts +0 -15
- package/src/types/time.d.ts +0 -16
- package/tsconfig.json +0 -17
- package/tsup.config.ts +0 -10
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
// src/core/time.ts
|
|
2
|
+
var pad = (n) => n.toString().padStart(2, "0");
|
|
3
|
+
function formatCurrentTime() {
|
|
4
|
+
const now = /* @__PURE__ */ new Date();
|
|
5
|
+
const hr24 = now.getHours();
|
|
6
|
+
const min = now.getMinutes();
|
|
7
|
+
const sec = now.getSeconds();
|
|
8
|
+
const period = hr24 >= 12 ? "PM" : "AM";
|
|
9
|
+
const hr12 = hr24 % 12 || 12;
|
|
10
|
+
return {
|
|
11
|
+
hr24,
|
|
12
|
+
hr12,
|
|
13
|
+
min,
|
|
14
|
+
sec,
|
|
15
|
+
period,
|
|
16
|
+
hr24Str: pad(hr24),
|
|
17
|
+
hr12Str: pad(hr12),
|
|
18
|
+
minStr: pad(min),
|
|
19
|
+
secStr: pad(sec),
|
|
20
|
+
timeAsString24: `${pad(hr24)}:${pad(min)}:${pad(sec)}`,
|
|
21
|
+
timeAsString12: `${pad(hr12)}:${pad(min)}:${pad(sec)} ${period}`
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function currentHour() {
|
|
25
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
26
|
+
const hr24 = currentTime.getHours();
|
|
27
|
+
const hr12 = hr24 % 12 || 12;
|
|
28
|
+
return {
|
|
29
|
+
hour24: hr24,
|
|
30
|
+
hour12: hr12,
|
|
31
|
+
hour24Str: pad(hr24),
|
|
32
|
+
hour12Str: pad(hr12)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function currentMinute() {
|
|
36
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
37
|
+
const minute = currentTime.getMinutes();
|
|
38
|
+
return {
|
|
39
|
+
minute,
|
|
40
|
+
minuteStr: pad(minute)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function currentSecond() {
|
|
44
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
45
|
+
const second = currentTime.getSeconds();
|
|
46
|
+
return {
|
|
47
|
+
second,
|
|
48
|
+
secondStr: pad(second)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function currentHour24Str() {
|
|
52
|
+
return currentHour().hour24Str;
|
|
53
|
+
}
|
|
54
|
+
function currentHour12Str() {
|
|
55
|
+
return currentHour().hour12Str;
|
|
56
|
+
}
|
|
57
|
+
function currentMinuteStr() {
|
|
58
|
+
return currentMinute().minuteStr;
|
|
59
|
+
}
|
|
60
|
+
function currentSecondStr() {
|
|
61
|
+
return currentSecond().secondStr;
|
|
62
|
+
}
|
|
63
|
+
function currentPeriod() {
|
|
64
|
+
const hr24 = (/* @__PURE__ */ new Date()).getHours();
|
|
65
|
+
const period = hr24 >= 12 ? "PM" : "AM";
|
|
66
|
+
return { period };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/response/timeResponse.ts
|
|
70
|
+
function getCurrentTime() {
|
|
71
|
+
const { timeAsString24, timeAsString12 } = formatCurrentTime();
|
|
72
|
+
return { timeAsString12, timeAsString24 };
|
|
73
|
+
}
|
|
74
|
+
function getCurrentTimeResponse() {
|
|
75
|
+
const time = formatCurrentTime();
|
|
76
|
+
const response = {
|
|
77
|
+
success: true,
|
|
78
|
+
code: 200,
|
|
79
|
+
msg: "Current time fetched successfully",
|
|
80
|
+
data: time
|
|
81
|
+
};
|
|
82
|
+
return response;
|
|
83
|
+
}
|
|
84
|
+
function getCurrentHr() {
|
|
85
|
+
return currentHour();
|
|
86
|
+
}
|
|
87
|
+
function getCurrenHrResponse() {
|
|
88
|
+
const hour = currentHour();
|
|
89
|
+
const response = {
|
|
90
|
+
success: true,
|
|
91
|
+
code: 200,
|
|
92
|
+
msg: "Current hour fetched successfully",
|
|
93
|
+
hour
|
|
94
|
+
};
|
|
95
|
+
return response;
|
|
96
|
+
}
|
|
97
|
+
function getCurrentMinute() {
|
|
98
|
+
return currentMinute();
|
|
99
|
+
}
|
|
100
|
+
function getCurrentMinuteResponse() {
|
|
101
|
+
const minute = currentMinute();
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
code: 200,
|
|
105
|
+
msg: "Current minute fetched successfully",
|
|
106
|
+
minute
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function getCurrentSecond() {
|
|
110
|
+
return currentSecond();
|
|
111
|
+
}
|
|
112
|
+
function getCurrentSecondResponse() {
|
|
113
|
+
const second = currentSecond();
|
|
114
|
+
return {
|
|
115
|
+
success: true,
|
|
116
|
+
code: 200,
|
|
117
|
+
msg: "Current second fetched successfully",
|
|
118
|
+
second
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function getCurrentHour24Str() {
|
|
122
|
+
return currentHour24Str();
|
|
123
|
+
}
|
|
124
|
+
function getCurrentHour24StrResponse() {
|
|
125
|
+
const value = currentHour24Str();
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
code: 200,
|
|
129
|
+
msg: "Current hour24 string fetched",
|
|
130
|
+
value
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function getCurrentHour12Str() {
|
|
134
|
+
return currentHour12Str();
|
|
135
|
+
}
|
|
136
|
+
function getCurrentHour12StrResponse() {
|
|
137
|
+
const value = currentHour12Str();
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
code: 200,
|
|
141
|
+
msg: "Current hour12 string fetched",
|
|
142
|
+
value
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function getCurrentMinuteStr() {
|
|
146
|
+
return currentMinuteStr();
|
|
147
|
+
}
|
|
148
|
+
function getCurrentMinuteStrResponse() {
|
|
149
|
+
const value = currentMinuteStr();
|
|
150
|
+
return {
|
|
151
|
+
success: true,
|
|
152
|
+
code: 200,
|
|
153
|
+
msg: "Current minute string fetched",
|
|
154
|
+
value
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function getCurrentSecondStr() {
|
|
158
|
+
return currentSecondStr();
|
|
159
|
+
}
|
|
160
|
+
function getCurrentSecondStrResponse() {
|
|
161
|
+
const value = currentSecondStr();
|
|
162
|
+
return {
|
|
163
|
+
success: true,
|
|
164
|
+
code: 200,
|
|
165
|
+
msg: "Current second string fetched",
|
|
166
|
+
value
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function getCurrentPeriod() {
|
|
170
|
+
return currentPeriod();
|
|
171
|
+
}
|
|
172
|
+
function getCurrentPeriodResponse() {
|
|
173
|
+
const period = currentPeriod();
|
|
174
|
+
return {
|
|
175
|
+
success: true,
|
|
176
|
+
code: 200,
|
|
177
|
+
msg: "Current period fetched successfully",
|
|
178
|
+
period
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/core/date.ts
|
|
183
|
+
var DAY_NAMES = [
|
|
184
|
+
"Sunday",
|
|
185
|
+
"Monday",
|
|
186
|
+
"Tuesday",
|
|
187
|
+
"Wednesday",
|
|
188
|
+
"Thursday",
|
|
189
|
+
"Friday",
|
|
190
|
+
"Saturday"
|
|
191
|
+
];
|
|
192
|
+
var MONTH_NAMES = [
|
|
193
|
+
"January",
|
|
194
|
+
"February",
|
|
195
|
+
"March",
|
|
196
|
+
"April",
|
|
197
|
+
"May",
|
|
198
|
+
"June",
|
|
199
|
+
"July",
|
|
200
|
+
"August",
|
|
201
|
+
"September",
|
|
202
|
+
"October",
|
|
203
|
+
"November",
|
|
204
|
+
"December"
|
|
205
|
+
];
|
|
206
|
+
function formatCurrentDate() {
|
|
207
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
208
|
+
const yr = currentDate.getFullYear();
|
|
209
|
+
const month = MONTH_NAMES[currentDate.getMonth()];
|
|
210
|
+
const day = DAY_NAMES[currentDate.getDay()];
|
|
211
|
+
const date = currentDate.getDate();
|
|
212
|
+
const ordinal = date === 1 ? "st" : date === 2 ? "nd" : date === 3 ? "rd" : "th";
|
|
213
|
+
const fullDate = `${month} ${date}${ordinal}, ${day}, ${yr}`;
|
|
214
|
+
return {
|
|
215
|
+
date: { yr, month, day, date, ordinal, fullDate }
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function currentYear() {
|
|
219
|
+
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
220
|
+
}
|
|
221
|
+
function currentMonth() {
|
|
222
|
+
const now = /* @__PURE__ */ new Date();
|
|
223
|
+
const idx = now.getMonth();
|
|
224
|
+
const monthNumber = idx + 1;
|
|
225
|
+
return {
|
|
226
|
+
monthNumber,
|
|
227
|
+
monthName: MONTH_NAMES[idx],
|
|
228
|
+
monthStr: monthNumber.toString().padStart(2, "0")
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function currentDay() {
|
|
232
|
+
const now = /* @__PURE__ */ new Date();
|
|
233
|
+
const idx = now.getDay();
|
|
234
|
+
return {
|
|
235
|
+
dayIndex: idx,
|
|
236
|
+
dayName: DAY_NAMES[idx]
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function currentDateNumber() {
|
|
240
|
+
const d = (/* @__PURE__ */ new Date()).getDate();
|
|
241
|
+
return {
|
|
242
|
+
date: d,
|
|
243
|
+
dateStr: d.toString().padStart(2, "0")
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function currentOrdinal() {
|
|
247
|
+
const d = (/* @__PURE__ */ new Date()).getDate();
|
|
248
|
+
const ordinal = d === 1 ? "st" : d === 2 ? "nd" : d === 3 ? "rd" : "th";
|
|
249
|
+
return { ordinal };
|
|
250
|
+
}
|
|
251
|
+
function currentFullDate() {
|
|
252
|
+
const now = /* @__PURE__ */ new Date();
|
|
253
|
+
const yr = now.getFullYear();
|
|
254
|
+
const month = MONTH_NAMES[now.getMonth()];
|
|
255
|
+
const day = DAY_NAMES[now.getDay()];
|
|
256
|
+
const date = now.getDate();
|
|
257
|
+
const ordinal = date === 1 ? "st" : date === 2 ? "nd" : date === 3 ? "rd" : "th";
|
|
258
|
+
const fullDate = `${month} ${date}${ordinal}, ${day}, ${yr}`;
|
|
259
|
+
return { fullDate };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/response/dateResponse.ts
|
|
263
|
+
function getCurrentDate() {
|
|
264
|
+
const { date } = formatCurrentDate();
|
|
265
|
+
const response = {
|
|
266
|
+
success: true,
|
|
267
|
+
code: 200,
|
|
268
|
+
msg: "Current date fetched successfully",
|
|
269
|
+
data: date
|
|
270
|
+
};
|
|
271
|
+
return response;
|
|
272
|
+
}
|
|
273
|
+
function getCurrentYear() {
|
|
274
|
+
return currentYear();
|
|
275
|
+
}
|
|
276
|
+
function getCurrentYearResponse() {
|
|
277
|
+
const value = currentYear();
|
|
278
|
+
return {
|
|
279
|
+
success: true,
|
|
280
|
+
code: 200,
|
|
281
|
+
msg: "Current year fetched successfully",
|
|
282
|
+
value
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function getCurrentMonth() {
|
|
286
|
+
return currentMonth();
|
|
287
|
+
}
|
|
288
|
+
function getCurrentMonthResponse() {
|
|
289
|
+
const value = currentMonth();
|
|
290
|
+
return {
|
|
291
|
+
success: true,
|
|
292
|
+
code: 200,
|
|
293
|
+
msg: "Current month fetched successfully",
|
|
294
|
+
value
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function getCurrentDay() {
|
|
298
|
+
return currentDay();
|
|
299
|
+
}
|
|
300
|
+
function getCurrentDayResponse() {
|
|
301
|
+
const value = currentDay();
|
|
302
|
+
return {
|
|
303
|
+
success: true,
|
|
304
|
+
code: 200,
|
|
305
|
+
msg: "Current day fetched successfully",
|
|
306
|
+
value
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function getCurrentDateNumber() {
|
|
310
|
+
return currentDateNumber();
|
|
311
|
+
}
|
|
312
|
+
function getCurrentDateNumberResponse() {
|
|
313
|
+
const value = currentDateNumber();
|
|
314
|
+
return {
|
|
315
|
+
success: true,
|
|
316
|
+
code: 200,
|
|
317
|
+
msg: "Current date number fetched successfully",
|
|
318
|
+
value
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function getCurrentOrdinal() {
|
|
322
|
+
return currentOrdinal();
|
|
323
|
+
}
|
|
324
|
+
function getCurrentOrdinalResponse() {
|
|
325
|
+
const value = currentOrdinal();
|
|
326
|
+
return {
|
|
327
|
+
success: true,
|
|
328
|
+
code: 200,
|
|
329
|
+
msg: "Current ordinal fetched successfully",
|
|
330
|
+
value
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function getCurrentFullDate() {
|
|
334
|
+
return currentFullDate();
|
|
335
|
+
}
|
|
336
|
+
function getCurrentFullDateResponse() {
|
|
337
|
+
const value = currentFullDate();
|
|
338
|
+
return {
|
|
339
|
+
success: true,
|
|
340
|
+
code: 200,
|
|
341
|
+
msg: "Current full date fetched successfully",
|
|
342
|
+
value
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
export {
|
|
346
|
+
getCurrenHrResponse,
|
|
347
|
+
getCurrentDate,
|
|
348
|
+
getCurrentDateNumber,
|
|
349
|
+
getCurrentDateNumberResponse,
|
|
350
|
+
getCurrentDay,
|
|
351
|
+
getCurrentDayResponse,
|
|
352
|
+
getCurrentFullDate,
|
|
353
|
+
getCurrentFullDateResponse,
|
|
354
|
+
getCurrentHour12Str,
|
|
355
|
+
getCurrentHour12StrResponse,
|
|
356
|
+
getCurrentHour24Str,
|
|
357
|
+
getCurrentHour24StrResponse,
|
|
358
|
+
getCurrentHr,
|
|
359
|
+
getCurrentMinute,
|
|
360
|
+
getCurrentMinuteResponse,
|
|
361
|
+
getCurrentMinuteStr,
|
|
362
|
+
getCurrentMinuteStrResponse,
|
|
363
|
+
getCurrentMonth,
|
|
364
|
+
getCurrentMonthResponse,
|
|
365
|
+
getCurrentOrdinal,
|
|
366
|
+
getCurrentOrdinalResponse,
|
|
367
|
+
getCurrentPeriod,
|
|
368
|
+
getCurrentPeriodResponse,
|
|
369
|
+
getCurrentSecond,
|
|
370
|
+
getCurrentSecondResponse,
|
|
371
|
+
getCurrentSecondStr,
|
|
372
|
+
getCurrentSecondStrResponse,
|
|
373
|
+
getCurrentTime,
|
|
374
|
+
getCurrentTimeResponse,
|
|
375
|
+
getCurrentYear,
|
|
376
|
+
getCurrentYearResponse
|
|
377
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clockey",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "API-first time utilities for backend developers",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"./dist/**/*"
|
|
10
|
+
],
|
|
8
11
|
"scripts": {
|
|
9
12
|
"build": "tsup"
|
|
10
13
|
},
|
package/src/core/date.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const DAY_NAMES = [
|
|
2
|
-
"Sunday",
|
|
3
|
-
"Monday",
|
|
4
|
-
"Tuesday",
|
|
5
|
-
"Wednesday",
|
|
6
|
-
"Thursday",
|
|
7
|
-
"Friday",
|
|
8
|
-
"Saturday",
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
const MONTH_NAMES = [
|
|
12
|
-
"January",
|
|
13
|
-
"February",
|
|
14
|
-
"March",
|
|
15
|
-
"April",
|
|
16
|
-
"May",
|
|
17
|
-
"June",
|
|
18
|
-
"July",
|
|
19
|
-
"August",
|
|
20
|
-
"September",
|
|
21
|
-
"October",
|
|
22
|
-
"November",
|
|
23
|
-
"December",
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export function formatCurrentDate() {
|
|
27
|
-
const currentDate = new Date();
|
|
28
|
-
|
|
29
|
-
const yr = currentDate.getFullYear();
|
|
30
|
-
const month = MONTH_NAMES[currentDate.getMonth()];
|
|
31
|
-
const day = DAY_NAMES[currentDate.getDay()];
|
|
32
|
-
const date = currentDate.getDate();
|
|
33
|
-
const ordinal =
|
|
34
|
-
date === 1 ? "st" : date === 2 ? "nd" : date === 3 ? "rd" : "th";
|
|
35
|
-
|
|
36
|
-
const fullDate = `${month} ${date}${ordinal}, ${day}, ${yr}`;
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
date: { yr, month, day, date, ordinal, fullDate },
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function currentYear() {
|
|
44
|
-
return new Date().getFullYear();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function currentMonth() {
|
|
48
|
-
const now = new Date();
|
|
49
|
-
const idx = now.getMonth();
|
|
50
|
-
const monthNumber = idx + 1;
|
|
51
|
-
return {
|
|
52
|
-
monthNumber,
|
|
53
|
-
monthName: MONTH_NAMES[idx],
|
|
54
|
-
monthStr: monthNumber.toString().padStart(2, "0"),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function currentDay() {
|
|
59
|
-
const now = new Date();
|
|
60
|
-
const idx = now.getDay();
|
|
61
|
-
return {
|
|
62
|
-
dayIndex: idx,
|
|
63
|
-
dayName: DAY_NAMES[idx],
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function currentDateNumber() {
|
|
68
|
-
const d = new Date().getDate();
|
|
69
|
-
return {
|
|
70
|
-
date: d,
|
|
71
|
-
dateStr: d.toString().padStart(2, "0"),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function currentOrdinal() {
|
|
76
|
-
const d = new Date().getDate();
|
|
77
|
-
const ordinal = d === 1 ? "st" : d === 2 ? "nd" : d === 3 ? "rd" : "th";
|
|
78
|
-
return { ordinal };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function currentFullDate() {
|
|
82
|
-
const now = new Date();
|
|
83
|
-
const yr = now.getFullYear();
|
|
84
|
-
const month = MONTH_NAMES[now.getMonth()];
|
|
85
|
-
const day = DAY_NAMES[now.getDay()];
|
|
86
|
-
const date = now.getDate();
|
|
87
|
-
const ordinal =
|
|
88
|
-
date === 1 ? "st" : date === 2 ? "nd" : date === 3 ? "rd" : "th";
|
|
89
|
-
const fullDate = `${month} ${date}${ordinal}, ${day}, ${yr}`;
|
|
90
|
-
return { fullDate };
|
|
91
|
-
}
|
package/src/core/time.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const pad = (n: number) => n.toString().padStart(2, "0");
|
|
2
|
-
|
|
3
|
-
export function formatCurrentTime() {
|
|
4
|
-
const now = new Date();
|
|
5
|
-
|
|
6
|
-
const hr24 = now.getHours();
|
|
7
|
-
const min = now.getMinutes();
|
|
8
|
-
const sec = now.getSeconds();
|
|
9
|
-
|
|
10
|
-
const period = hr24 >= 12 ? "PM" : "AM";
|
|
11
|
-
const hr12 = hr24 % 12 || 12;
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
hr24,
|
|
15
|
-
hr12,
|
|
16
|
-
min,
|
|
17
|
-
sec,
|
|
18
|
-
period,
|
|
19
|
-
hr24Str: pad(hr24),
|
|
20
|
-
hr12Str: pad(hr12),
|
|
21
|
-
minStr: pad(min),
|
|
22
|
-
secStr: pad(sec),
|
|
23
|
-
timeAsString24: `${pad(hr24)}:${pad(min)}:${pad(sec)}`,
|
|
24
|
-
timeAsString12: `${pad(hr12)}:${pad(min)}:${pad(sec)} ${period}`,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function currentHour() {
|
|
29
|
-
const currentTime = new Date();
|
|
30
|
-
const hr24 = currentTime.getHours();
|
|
31
|
-
const hr12 = hr24 % 12 || 12;
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
hour24: hr24,
|
|
35
|
-
hour12: hr12,
|
|
36
|
-
hour24Str: pad(hr24),
|
|
37
|
-
hour12Str: pad(hr12),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function currentMinute() {
|
|
42
|
-
const currentTime = new Date();
|
|
43
|
-
const minute = currentTime.getMinutes();
|
|
44
|
-
return {
|
|
45
|
-
minute,
|
|
46
|
-
minuteStr: pad(minute),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function currentSecond() {
|
|
51
|
-
const currentTime = new Date();
|
|
52
|
-
const second = currentTime.getSeconds();
|
|
53
|
-
return {
|
|
54
|
-
second,
|
|
55
|
-
secondStr: pad(second),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// String Based Responses
|
|
60
|
-
export function currentHour24Str() {
|
|
61
|
-
return currentHour().hour24Str;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function currentHour12Str() {
|
|
65
|
-
return currentHour().hour12Str;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function currentMinuteStr() {
|
|
69
|
-
return currentMinute().minuteStr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function currentSecondStr() {
|
|
73
|
-
return currentSecond().secondStr;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function currentPeriod() {
|
|
77
|
-
const hr24 = new Date().getHours();
|
|
78
|
-
const period = hr24 >= 12 ? "PM" : "AM";
|
|
79
|
-
return { period };
|
|
80
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatCurrentDate,
|
|
3
|
-
currentYear,
|
|
4
|
-
currentMonth,
|
|
5
|
-
currentDay,
|
|
6
|
-
currentDateNumber,
|
|
7
|
-
currentOrdinal,
|
|
8
|
-
currentFullDate,
|
|
9
|
-
} from "../core/date";
|
|
10
|
-
import { ClockeyDateResponse } from "../types/date";
|
|
11
|
-
|
|
12
|
-
export function getCurrentDate() {
|
|
13
|
-
const { date } = formatCurrentDate();
|
|
14
|
-
const response: ClockeyDateResponse = {
|
|
15
|
-
success: true,
|
|
16
|
-
code: 200,
|
|
17
|
-
msg: "Current date fetched successfully",
|
|
18
|
-
data: date,
|
|
19
|
-
};
|
|
20
|
-
return response;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getCurrentYear() {
|
|
24
|
-
return currentYear();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function getCurrentYearResponse() {
|
|
28
|
-
const value = currentYear();
|
|
29
|
-
return {
|
|
30
|
-
success: true,
|
|
31
|
-
code: 200,
|
|
32
|
-
msg: "Current year fetched successfully",
|
|
33
|
-
value,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function getCurrentMonth() {
|
|
38
|
-
return currentMonth();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getCurrentMonthResponse() {
|
|
42
|
-
const value = currentMonth();
|
|
43
|
-
return {
|
|
44
|
-
success: true,
|
|
45
|
-
code: 200,
|
|
46
|
-
msg: "Current month fetched successfully",
|
|
47
|
-
value,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function getCurrentDay() {
|
|
52
|
-
return currentDay();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function getCurrentDayResponse() {
|
|
56
|
-
const value = currentDay();
|
|
57
|
-
return {
|
|
58
|
-
success: true,
|
|
59
|
-
code: 200,
|
|
60
|
-
msg: "Current day fetched successfully",
|
|
61
|
-
value,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function getCurrentDateNumber() {
|
|
66
|
-
return currentDateNumber();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function getCurrentDateNumberResponse() {
|
|
70
|
-
const value = currentDateNumber();
|
|
71
|
-
return {
|
|
72
|
-
success: true,
|
|
73
|
-
code: 200,
|
|
74
|
-
msg: "Current date number fetched successfully",
|
|
75
|
-
value,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function getCurrentOrdinal() {
|
|
80
|
-
return currentOrdinal();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function getCurrentOrdinalResponse() {
|
|
84
|
-
const value = currentOrdinal();
|
|
85
|
-
return {
|
|
86
|
-
success: true,
|
|
87
|
-
code: 200,
|
|
88
|
-
msg: "Current ordinal fetched successfully",
|
|
89
|
-
value,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function getCurrentFullDate() {
|
|
94
|
-
return currentFullDate();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function getCurrentFullDateResponse() {
|
|
98
|
-
const value = currentFullDate();
|
|
99
|
-
return {
|
|
100
|
-
success: true,
|
|
101
|
-
code: 200,
|
|
102
|
-
msg: "Current full date fetched successfully",
|
|
103
|
-
value,
|
|
104
|
-
};
|
|
105
|
-
}
|