1 | import { dateToDash } from '@valjoux/convert';
|
2 | import { formatDateTime } from '@valjoux/format-date-time';
|
3 | import { formatTime } from '@valjoux/format-time';
|
4 |
|
5 | const padMilli = ms => (ms = '' + ms).length > 2 ? ms : ('00' + ms).slice(-3);
|
6 | const milli = date => padMilli(date.getMilliseconds());
|
7 |
|
8 |
|
9 |
|
10 | const date = (dt = new Date(), dash = '-') => dateToDash(dt, dash);
|
11 |
|
12 |
|
13 | const roughTime = (date = new Date()) => formatTime(date);
|
14 |
|
15 |
|
16 | const time = (date = new Date()) => formatTime(date) + '.' + milli(date);
|
17 |
|
18 |
|
19 | const dateTime = (date = new Date()) => formatDateTime(date);
|
20 |
|
21 |
|
22 | const year = (date = new Date()) => date.getFullYear();
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | const today = (dash = '-') => dateToDash(new Date(), dash);
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | const roughly = (date = new Date()) => formatTime(date);
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | const roughlyNow = () => formatTime(new Date());
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | const now = () => {
|
47 | var _Date;
|
48 |
|
49 | return _Date = new Date(), time(_Date);
|
50 | };
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | const present = () => formatDateTime(new Date());
|
57 |
|
58 | export { date, dateTime, now, present, roughTime, roughly, roughlyNow, time, today, year };
|