@bemoje/date 1.0.0 → 1.1.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/README.md +108 -0
- package/lib/Timer.cjs +21 -0
- package/lib/Timer.d.cts +6 -0
- package/lib/Timer.d.ts +6 -0
- package/lib/Timer.js +18 -0
- package/lib/dateString.cjs +12 -0
- package/lib/dateString.d.cts +6 -0
- package/lib/dateString.d.ts +6 -0
- package/lib/dateString.js +9 -0
- package/lib/daysToMs.cjs +10 -0
- package/lib/daysToMs.d.cts +6 -0
- package/lib/daysToMs.d.ts +6 -0
- package/lib/daysToMs.js +8 -0
- package/lib/getWeek.cjs +15 -0
- package/lib/getWeek.d.cts +6 -0
- package/lib/getWeek.d.ts +6 -0
- package/lib/getWeek.js +12 -0
- package/lib/hasCooldownElapsed.cjs +11 -0
- package/lib/hasCooldownElapsed.d.cts +10 -0
- package/lib/hasCooldownElapsed.d.ts +10 -0
- package/lib/hasCooldownElapsed.js +9 -0
- package/lib/hoursToMs.cjs +10 -0
- package/lib/hoursToMs.d.cts +6 -0
- package/lib/hoursToMs.d.ts +6 -0
- package/lib/hoursToMs.js +8 -0
- package/lib/index.cjs +103 -0
- package/lib/index.d.cts +14 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +14 -0
- package/lib/minutesToMs.cjs +10 -0
- package/lib/minutesToMs.d.cts +6 -0
- package/lib/minutesToMs.d.ts +6 -0
- package/lib/minutesToMs.js +8 -0
- package/lib/monthNameDa.cjs +28 -0
- package/lib/monthNameDa.d.cts +14 -0
- package/lib/monthNameDa.d.ts +14 -0
- package/lib/monthNameDa.js +26 -0
- package/lib/monthNameDaRelative.cjs +13 -0
- package/lib/monthNameDaRelative.d.cts +13 -0
- package/lib/monthNameDaRelative.d.ts +13 -0
- package/lib/monthNameDaRelative.js +10 -0
- package/lib/msSinceDate.cjs +10 -0
- package/lib/msSinceDate.d.cts +6 -0
- package/lib/msSinceDate.d.ts +6 -0
- package/lib/msSinceDate.js +8 -0
- package/lib/secondsToMs.cjs +10 -0
- package/lib/secondsToMs.d.cts +6 -0
- package/lib/secondsToMs.d.ts +6 -0
- package/lib/secondsToMs.js +8 -0
- package/lib/stripTime.cjs +10 -0
- package/lib/stripTime.d.cts +6 -0
- package/lib/stripTime.d.ts +6 -0
- package/lib/stripTime.js +8 -0
- package/lib/today.cjs +12 -0
- package/lib/today.d.cts +6 -0
- package/lib/today.d.ts +6 -0
- package/lib/today.js +9 -0
- package/lib/yesterday.cjs +14 -0
- package/lib/yesterday.d.cts +6 -0
- package/lib/yesterday.d.ts +6 -0
- package/lib/yesterday.js +11 -0
- package/package.json +236 -19
- package/index.d.ts +0 -90
- package/index.mjs +0 -112
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @bemoje/date
|
|
2
|
+
|
|
3
|
+
Lightweight date and time utilities for formatting, time-unit conversion, and duration measurement.
|
|
4
|
+
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://nodejs.org/api/esm.html)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @bemoje/date
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Date Formatting
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { dateString, today, yesterday } from '@bemoje/date'
|
|
20
|
+
|
|
21
|
+
dateString()
|
|
22
|
+
// => '2026-02-28'
|
|
23
|
+
|
|
24
|
+
dateString(new Date(2025, 0, 15))
|
|
25
|
+
// => '2025-01-15'
|
|
26
|
+
|
|
27
|
+
today()
|
|
28
|
+
// => Date object for today at 00:00:00
|
|
29
|
+
|
|
30
|
+
yesterday()
|
|
31
|
+
// => Date object for yesterday at 00:00:00
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Time Unit Conversion
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { daysToMs, hoursToMs, minutesToMs, secondsToMs } from '@bemoje/date'
|
|
38
|
+
|
|
39
|
+
daysToMs(1) // => 86400000
|
|
40
|
+
hoursToMs(2) // => 7200000
|
|
41
|
+
minutesToMs(30) // => 1800000
|
|
42
|
+
secondsToMs(45) // => 45000
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Duration & Cooldowns
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { msSinceDate, hasCooldownElapsed, Timer } from '@bemoje/date'
|
|
49
|
+
|
|
50
|
+
// Milliseconds elapsed since a date
|
|
51
|
+
const start = new Date('2026-02-01')
|
|
52
|
+
msSinceDate(start)
|
|
53
|
+
// => number of ms since Feb 1
|
|
54
|
+
|
|
55
|
+
// Check if a cooldown period has passed
|
|
56
|
+
hasCooldownElapsed(start, daysToMs(7))
|
|
57
|
+
// => true (if more than 7 days have passed)
|
|
58
|
+
|
|
59
|
+
// Stopwatch-style timer
|
|
60
|
+
const elapsed = Timer()
|
|
61
|
+
// ... do some work ...
|
|
62
|
+
elapsed()
|
|
63
|
+
// => '142ms' (human-readable duration string)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Week & Date Operations
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { getWeek, stripTime } from '@bemoje/date'
|
|
70
|
+
|
|
71
|
+
getWeek(new Date('2026-02-28'))
|
|
72
|
+
// => 9
|
|
73
|
+
|
|
74
|
+
// Remove time component from a Date
|
|
75
|
+
stripTime(new Date('2026-02-28T15:30:00'))
|
|
76
|
+
// => Date('2026-02-28T00:00:00')
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Danish Month Names
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { monthNameDa, monthNameDaRelative } from '@bemoje/date'
|
|
83
|
+
|
|
84
|
+
monthNameDa(new Date('2026-03-15'))
|
|
85
|
+
// => 'Marts'
|
|
86
|
+
|
|
87
|
+
monthNameDaRelative(new Date())
|
|
88
|
+
// => relative month name in Danish
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API Reference
|
|
92
|
+
|
|
93
|
+
| Export | Description |
|
|
94
|
+
| --------------------- | -------------------------------------------- |
|
|
95
|
+
| `dateString` | Format date as `yyyy-MM-dd` |
|
|
96
|
+
| `today` | Today's date with time stripped |
|
|
97
|
+
| `yesterday` | Yesterday's date |
|
|
98
|
+
| `stripTime` | Remove time component from a Date |
|
|
99
|
+
| `getWeek` | ISO week number |
|
|
100
|
+
| `msSinceDate` | Milliseconds elapsed since a date |
|
|
101
|
+
| `hasCooldownElapsed` | Check if a cooldown period has passed |
|
|
102
|
+
| `Timer` | Returns a function that reports elapsed time |
|
|
103
|
+
| `daysToMs` | Convert days to milliseconds |
|
|
104
|
+
| `hoursToMs` | Convert hours to milliseconds |
|
|
105
|
+
| `minutesToMs` | Convert minutes to milliseconds |
|
|
106
|
+
| `secondsToMs` | Convert seconds to milliseconds |
|
|
107
|
+
| `monthNameDa` | Danish month name |
|
|
108
|
+
| `monthNameDaRelative` | Relative Danish month name |
|
package/lib/Timer.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var enhancedMs = require('enhanced-ms');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function Timer(startTime = Date.now()) {
|
|
8
|
+
return function(endTime = Date.now()) {
|
|
9
|
+
const duration = endTime - startTime;
|
|
10
|
+
if (duration === 0) {
|
|
11
|
+
return "0ms";
|
|
12
|
+
}
|
|
13
|
+
const string = enhancedMs.ms(duration, {
|
|
14
|
+
useAbbreviations: true
|
|
15
|
+
});
|
|
16
|
+
return string ?? `${duration}ms`;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
__name(Timer, "Timer");
|
|
20
|
+
|
|
21
|
+
exports.Timer = Timer;
|
package/lib/Timer.d.cts
ADDED
package/lib/Timer.d.ts
ADDED
package/lib/Timer.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
import { ms } from 'enhanced-ms';
|
|
3
|
+
|
|
4
|
+
function Timer(startTime = Date.now()) {
|
|
5
|
+
return function(endTime = Date.now()) {
|
|
6
|
+
const duration = endTime - startTime;
|
|
7
|
+
if (duration === 0) {
|
|
8
|
+
return "0ms";
|
|
9
|
+
}
|
|
10
|
+
const string = ms(duration, {
|
|
11
|
+
useAbbreviations: true
|
|
12
|
+
});
|
|
13
|
+
return string ?? `${duration}ms`;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
__name(Timer, "Timer");
|
|
17
|
+
|
|
18
|
+
export { Timer };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dateFns = require('date-fns');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function dateString(date) {
|
|
8
|
+
return dateFns.format(date ? new Date(date) : /* @__PURE__ */ new Date(), "yyyy-MM-dd");
|
|
9
|
+
}
|
|
10
|
+
__name(dateString, "dateString");
|
|
11
|
+
|
|
12
|
+
exports.dateString = dateString;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
import { format } from 'date-fns';
|
|
3
|
+
|
|
4
|
+
function dateString(date) {
|
|
5
|
+
return format(date ? new Date(date) : /* @__PURE__ */ new Date(), "yyyy-MM-dd");
|
|
6
|
+
}
|
|
7
|
+
__name(dateString, "dateString");
|
|
8
|
+
|
|
9
|
+
export { dateString };
|
package/lib/daysToMs.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function daysToMs(days) {
|
|
6
|
+
return 1e3 * 60 * 60 * 24 * days;
|
|
7
|
+
}
|
|
8
|
+
__name(daysToMs, "daysToMs");
|
|
9
|
+
|
|
10
|
+
exports.daysToMs = daysToMs;
|
package/lib/daysToMs.js
ADDED
package/lib/getWeek.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var locale = require('date-fns/locale');
|
|
4
|
+
var dateFns = require('date-fns');
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
function getWeek(date) {
|
|
9
|
+
return dateFns.getWeek(date, {
|
|
10
|
+
locale: locale.da
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
__name(getWeek, "getWeek");
|
|
14
|
+
|
|
15
|
+
exports.getWeek = getWeek;
|
package/lib/getWeek.d.ts
ADDED
package/lib/getWeek.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
import { da } from 'date-fns/locale';
|
|
3
|
+
import { getWeek as getWeek$1 } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
function getWeek(date) {
|
|
6
|
+
return getWeek$1(date, {
|
|
7
|
+
locale: da
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
__name(getWeek, "getWeek");
|
|
11
|
+
|
|
12
|
+
export { getWeek };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function hasCooldownElapsed(startDate, cooldownMs) {
|
|
6
|
+
const elapsedMs = Date.now() - startDate.getTime();
|
|
7
|
+
return elapsedMs > cooldownMs;
|
|
8
|
+
}
|
|
9
|
+
__name(hasCooldownElapsed, "hasCooldownElapsed");
|
|
10
|
+
|
|
11
|
+
exports.hasCooldownElapsed = hasCooldownElapsed;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines if a specified cooldown period has elapsed since a given date.
|
|
3
|
+
*
|
|
4
|
+
* @param startDate - The starting date to calculate elapsed time from.
|
|
5
|
+
* @param cooldownMs - The cooldown duration in milliseconds.
|
|
6
|
+
* @returns `true` if the cooldown period has elapsed, otherwise `false`.
|
|
7
|
+
*/
|
|
8
|
+
declare function hasCooldownElapsed(startDate: Date, cooldownMs: number): boolean;
|
|
9
|
+
|
|
10
|
+
export { hasCooldownElapsed };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines if a specified cooldown period has elapsed since a given date.
|
|
3
|
+
*
|
|
4
|
+
* @param startDate - The starting date to calculate elapsed time from.
|
|
5
|
+
* @param cooldownMs - The cooldown duration in milliseconds.
|
|
6
|
+
* @returns `true` if the cooldown period has elapsed, otherwise `false`.
|
|
7
|
+
*/
|
|
8
|
+
declare function hasCooldownElapsed(startDate: Date, cooldownMs: number): boolean;
|
|
9
|
+
|
|
10
|
+
export { hasCooldownElapsed };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
|
|
3
|
+
function hasCooldownElapsed(startDate, cooldownMs) {
|
|
4
|
+
const elapsedMs = Date.now() - startDate.getTime();
|
|
5
|
+
return elapsedMs > cooldownMs;
|
|
6
|
+
}
|
|
7
|
+
__name(hasCooldownElapsed, "hasCooldownElapsed");
|
|
8
|
+
|
|
9
|
+
export { hasCooldownElapsed };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function hoursToMs(hours) {
|
|
6
|
+
return 1e3 * 60 * 60 * hours;
|
|
7
|
+
}
|
|
8
|
+
__name(hoursToMs, "hoursToMs");
|
|
9
|
+
|
|
10
|
+
exports.hoursToMs = hoursToMs;
|
package/lib/hoursToMs.js
ADDED
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Timer = require('./Timer');
|
|
4
|
+
var dateString = require('./dateString');
|
|
5
|
+
var daysToMs = require('./daysToMs');
|
|
6
|
+
var getWeek = require('./getWeek');
|
|
7
|
+
var hasCooldownElapsed = require('./hasCooldownElapsed');
|
|
8
|
+
var hoursToMs = require('./hoursToMs');
|
|
9
|
+
var minutesToMs = require('./minutesToMs');
|
|
10
|
+
var monthNameDa = require('./monthNameDa');
|
|
11
|
+
var monthNameDaRelative = require('./monthNameDaRelative');
|
|
12
|
+
var msSinceDate = require('./msSinceDate');
|
|
13
|
+
var secondsToMs = require('./secondsToMs');
|
|
14
|
+
var stripTime = require('./stripTime');
|
|
15
|
+
var today = require('./today');
|
|
16
|
+
var yesterday = require('./yesterday');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Object.keys(Timer).forEach(function (k) {
|
|
21
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return Timer[k]; }
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
Object.keys(dateString).forEach(function (k) {
|
|
27
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return dateString[k]; }
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
Object.keys(daysToMs).forEach(function (k) {
|
|
33
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return daysToMs[k]; }
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Object.keys(getWeek).forEach(function (k) {
|
|
39
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return getWeek[k]; }
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
Object.keys(hasCooldownElapsed).forEach(function (k) {
|
|
45
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return hasCooldownElapsed[k]; }
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
Object.keys(hoursToMs).forEach(function (k) {
|
|
51
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return hoursToMs[k]; }
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
Object.keys(minutesToMs).forEach(function (k) {
|
|
57
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return minutesToMs[k]; }
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
Object.keys(monthNameDa).forEach(function (k) {
|
|
63
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return monthNameDa[k]; }
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
Object.keys(monthNameDaRelative).forEach(function (k) {
|
|
69
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return monthNameDaRelative[k]; }
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
Object.keys(msSinceDate).forEach(function (k) {
|
|
75
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () { return msSinceDate[k]; }
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
Object.keys(secondsToMs).forEach(function (k) {
|
|
81
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return secondsToMs[k]; }
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
Object.keys(stripTime).forEach(function (k) {
|
|
87
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () { return stripTime[k]; }
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
Object.keys(today).forEach(function (k) {
|
|
93
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () { return today[k]; }
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
Object.keys(yesterday).forEach(function (k) {
|
|
99
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () { return yesterday[k]; }
|
|
102
|
+
});
|
|
103
|
+
});
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Timer } from './Timer.cjs';
|
|
2
|
+
export { dateString } from './dateString.cjs';
|
|
3
|
+
export { daysToMs } from './daysToMs.cjs';
|
|
4
|
+
export { getWeek } from './getWeek.cjs';
|
|
5
|
+
export { hasCooldownElapsed } from './hasCooldownElapsed.cjs';
|
|
6
|
+
export { hoursToMs } from './hoursToMs.cjs';
|
|
7
|
+
export { minutesToMs } from './minutesToMs.cjs';
|
|
8
|
+
export { monthNameDa } from './monthNameDa.cjs';
|
|
9
|
+
export { monthNameDaRelative } from './monthNameDaRelative.cjs';
|
|
10
|
+
export { msSinceDate } from './msSinceDate.cjs';
|
|
11
|
+
export { secondsToMs } from './secondsToMs.cjs';
|
|
12
|
+
export { stripTime } from './stripTime.cjs';
|
|
13
|
+
export { today } from './today.cjs';
|
|
14
|
+
export { yesterday } from './yesterday.cjs';
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Timer } from './Timer.js';
|
|
2
|
+
export { dateString } from './dateString.js';
|
|
3
|
+
export { daysToMs } from './daysToMs.js';
|
|
4
|
+
export { getWeek } from './getWeek.js';
|
|
5
|
+
export { hasCooldownElapsed } from './hasCooldownElapsed.js';
|
|
6
|
+
export { hoursToMs } from './hoursToMs.js';
|
|
7
|
+
export { minutesToMs } from './minutesToMs.js';
|
|
8
|
+
export { monthNameDa } from './monthNameDa.js';
|
|
9
|
+
export { monthNameDaRelative } from './monthNameDaRelative.js';
|
|
10
|
+
export { msSinceDate } from './msSinceDate.js';
|
|
11
|
+
export { secondsToMs } from './secondsToMs.js';
|
|
12
|
+
export { stripTime } from './stripTime.js';
|
|
13
|
+
export { today } from './today.js';
|
|
14
|
+
export { yesterday } from './yesterday.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './Timer';
|
|
2
|
+
export * from './dateString';
|
|
3
|
+
export * from './daysToMs';
|
|
4
|
+
export * from './getWeek';
|
|
5
|
+
export * from './hasCooldownElapsed';
|
|
6
|
+
export * from './hoursToMs';
|
|
7
|
+
export * from './minutesToMs';
|
|
8
|
+
export * from './monthNameDa';
|
|
9
|
+
export * from './monthNameDaRelative';
|
|
10
|
+
export * from './msSinceDate';
|
|
11
|
+
export * from './secondsToMs';
|
|
12
|
+
export * from './stripTime';
|
|
13
|
+
export * from './today';
|
|
14
|
+
export * from './yesterday';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function minutesToMs(minutes) {
|
|
6
|
+
return 1e3 * 60 * minutes;
|
|
7
|
+
}
|
|
8
|
+
__name(minutesToMs, "minutesToMs");
|
|
9
|
+
|
|
10
|
+
exports.minutesToMs = minutesToMs;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function monthNameDa(month) {
|
|
6
|
+
if (month < 1 || month > 12) {
|
|
7
|
+
throw new Error(`Invalid month number. Got: ${month}`);
|
|
8
|
+
}
|
|
9
|
+
return MONTH_NAMES_DA[month];
|
|
10
|
+
}
|
|
11
|
+
__name(monthNameDa, "monthNameDa");
|
|
12
|
+
const MONTH_NAMES_DA = [
|
|
13
|
+
"",
|
|
14
|
+
"Januar",
|
|
15
|
+
"Februar",
|
|
16
|
+
"Marts",
|
|
17
|
+
"April",
|
|
18
|
+
"Maj",
|
|
19
|
+
"Juni",
|
|
20
|
+
"Juli",
|
|
21
|
+
"August",
|
|
22
|
+
"September",
|
|
23
|
+
"Oktober",
|
|
24
|
+
"November",
|
|
25
|
+
"December"
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
exports.monthNameDa = monthNameDa;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the name, in Danish language, of the month corresponding to the provided month number.
|
|
3
|
+
*
|
|
4
|
+
* @param month - A month number between 1 and 12.
|
|
5
|
+
*
|
|
6
|
+
* @throws if the provided month number is not a valid month.
|
|
7
|
+
*
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* monthNameDA(9) //=> 'September'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
declare function monthNameDa(month: number): string;
|
|
13
|
+
|
|
14
|
+
export { monthNameDa };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the name, in Danish language, of the month corresponding to the provided month number.
|
|
3
|
+
*
|
|
4
|
+
* @param month - A month number between 1 and 12.
|
|
5
|
+
*
|
|
6
|
+
* @throws if the provided month number is not a valid month.
|
|
7
|
+
*
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* monthNameDA(9) //=> 'September'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
declare function monthNameDa(month: number): string;
|
|
13
|
+
|
|
14
|
+
export { monthNameDa };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
|
|
3
|
+
function monthNameDa(month) {
|
|
4
|
+
if (month < 1 || month > 12) {
|
|
5
|
+
throw new Error(`Invalid month number. Got: ${month}`);
|
|
6
|
+
}
|
|
7
|
+
return MONTH_NAMES_DA[month];
|
|
8
|
+
}
|
|
9
|
+
__name(monthNameDa, "monthNameDa");
|
|
10
|
+
const MONTH_NAMES_DA = [
|
|
11
|
+
"",
|
|
12
|
+
"Januar",
|
|
13
|
+
"Februar",
|
|
14
|
+
"Marts",
|
|
15
|
+
"April",
|
|
16
|
+
"Maj",
|
|
17
|
+
"Juni",
|
|
18
|
+
"Juli",
|
|
19
|
+
"August",
|
|
20
|
+
"September",
|
|
21
|
+
"Oktober",
|
|
22
|
+
"November",
|
|
23
|
+
"December"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export { monthNameDa };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dateFns = require('date-fns');
|
|
4
|
+
var monthNameDa = require('./monthNameDa');
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
function monthNameDaRelative(n) {
|
|
9
|
+
return monthNameDa.monthNameDa(dateFns.addMonths(/* @__PURE__ */ new Date(), n).getUTCMonth() + 1);
|
|
10
|
+
}
|
|
11
|
+
__name(monthNameDaRelative, "monthNameDaRelative");
|
|
12
|
+
|
|
13
|
+
exports.monthNameDaRelative = monthNameDaRelative;
|