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