1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
use ;
use ;
/// ### calc_date(total_seconds: u64) -> (u64, u64, u64)
///
/// Calculates the date (year, month, day) from total seconds since the UNIX epoch.
///
/// This function takes a count of seconds since the UNIX epoch and computes the corresponding
/// calendar date.
///
/// ### Example
///
/// ```
/// use wtime::calc::calc_date;
///
/// let seconds = 1_600_000_000; // Example total seconds since UNIX epoch
/// let (year, month, day) = calc_date(seconds);
/// println!("Date: {}-{}-{}", year, month, day);
/// assert_eq!(calc_date(1728933069), (2024, 10, 14));
/// ```
///
/// ### Returns
///
/// Returns a tuple containing the year, month, and day extracted from the total seconds.
///
/// <small>End Fun Doc</small>
/// ### calc_week(date: (u64, u64, u64)) -> u64
///
/// Calculates the week number in the year based on a provided date.
///
/// The function takes a date in the format `(year, month, day)` and returns the week number
/// according to the ISO 8601 standard (where the first week of the year is the week
/// containing the first Thursday).
///
/// ### Example
///
/// ```rust
/// use wtime::calc::calc_week;
///
/// let week_number = calc_week((2024, 10, 14));
/// println!("Week number: {}", week_number);
/// ```
///
/// ### Returns
///
/// Returns the week number as a `u64`.
///
/// <small>End Fun Doc</small>
/// ### duration_since()
///
/// Returns the duration from the UNIX epoch to the current time.
///
/// This function calculates the amount of time that has elapsed since the UNIX epoch
/// (January 1, 1970) and returns it as a `Duration`. This can be useful for calculations
/// involving specific time intervals.
///
/// ### Example
///
/// ```
/// use wtime::calc::duration_since;
///
/// let duration = duration_since();
/// println!("Seconds since UNIX epoch: {:?}", duration.as_secs());
/// println!("Milli-seconds since UNIX epoch: {:?}", duration_since().as_millis());
/// ```
///
/// ### Panics
///
/// This function will panic if the current system time is before the UNIX epoch.
///
/// <small>End Fun Doc</small>
/// ### get_day_name(total_seconds: u64) -> &'static str
///
/// Returns the name of the day of the week corresponding to the total seconds since the UNIX epoch.
///
/// This function calculates the day name based on the total seconds since the UNIX epoch.
///
/// ### Example
///
/// ```
/// use wtime::calc::get_day_name;
/// use wtime::utc::get_day;
///
/// let day = get_day();
/// println!("Current day: {}", day);
///
/// let day_name = get_day_name(1_670_000_000);
/// println!("Day name: {}", day_name); // Day name: Friday
/// println!("Day name: {}", get_day_name(day));
/// ```
///
/// ### Returns
///
/// Returns the name of the day as a static string reference.
///
/// <small>End Fun Doc</small>
/// ### get_month_name(month: u64) -> &'static str
///
/// Returns the name of the month corresponding to the provided month number.
///
/// This function takes a month number (from 1 to 12) and returns the corresponding month name.
///
/// ### Example
///
/// ```
/// use wtime::calc::get_month_name;
/// use wtime::utc::get_month;
///
/// let month = get_month();
/// println!("Current month: {}", month);
///
/// let month_name = get_month_name(4);
/// println!("Month name: {}", month_name); // "April"
/// println!("Month name: {}", get_month_name(month));
/// ```
///
/// ### Panics
///
/// This function will panic if provided with an invalid month number (not between 1 and 12).
///
/// <small>End Fun Doc</small>
/// ### is_leap_year(year: u64) -> bool
///
/// Determines if a given year is a leap year.
///
/// This function checks if the provided year is a leap year according to the rules:
/// a year is a leap year if it is divisible by 4 but not divisible by 100, except for years
/// that are divisible by 400.
///
/// ### Example
///
/// ```
/// use wtime::calc::is_leap_year;
/// use wtime::utc::get_year;
///
/// let year = 2024;
/// println!("Is {} a leap year? {}", year, is_leap_year(year)); // true
/// println!("Is {} a leap year? {}", year, is_leap_year(get_year()));
/// ```
///
/// ### Returns
///
/// Returns `true` if the year is a leap year, otherwise returns `false`.
///
/// <small>End Fun Doc</small>
/// ### get_minute() -> u64
///
/// Retrieves the current minute of the hour.
///
/// This function calculates the current minute based on the current UTC timestamp.
///
/// ### Example
///
/// ```
/// use wtime::calc::get_minute;
///
/// let minute = get_minute();
/// println!("Current minute: {}", minute);
/// ```
///
/// ### Returns
///
/// Returns the current minute of the hour as a `u64`.
///
/// <small>End Fun Doc</small>
/// ### get_second() -> u64
///
/// Retrieves the current second of the minute.
///
/// This function calculates the current second based on the current UTC timestamp.
///
/// ### Example
///
/// ```
/// use wtime::calc::get_second;
///
/// let second = get_second();
/// println!("Current second: {}", second);
/// ```
///
/// ### Returns
///
/// Returns the current second of the minute as a `u64`.
///
/// <small>End Fun Doc</small>
/// ### get_millis() -> u64
///
/// Retrieves the current milliseconds based on the elapsed time since the UNIX epoch.
///
/// This function calculates the current elapsed milliseconds since the UNIX epoch
/// and returns only the millisecond component (0-999).
///
/// ### Example
///
/// ```
/// use wtime::calc::get_millis;
///
/// let millis = get_millis();
/// println!("Current milliseconds: {}", millis);
/// ```
///
/// ### Returns
///
/// Returns the current milliseconds as a `u64`.
///
/// <small>End Fun Doc</small>
/// ### get_nanos() -> u64
///
/// Retrieves the current nanoseconds based on the elapsed time since the UNIX epoch.
///
/// This function calculates the current elapsed nanoseconds since the UNIX epoch
/// and returns only the nanosecond component (0-999,999).
///
/// ### Example
///
/// ```
/// use wtime::calc::get_nanos;
///
/// let nanos = get_nanos();
/// println!("Current nanoseconds: {}", nanos);
/// ```
///
/// ### Returns
///
/// Returns the current nanoseconds as a `u64`.
///
/// <small>End Fun Doc</small>