mark-3 0.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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/helpers/date/format/README.md +33 -0
- package/helpers/date/format/index.js +60 -0
- package/helpers/date/format/index.test.js +97 -0
- package/helpers/date/from-timestamp/README.md +14 -0
- package/helpers/date/from-timestamp/index.js +34 -0
- package/helpers/date/from-timestamp/index.test.js +64 -0
- package/helpers/date/index.js +4 -0
- package/helpers/date/is-on-same-day/README.md +12 -0
- package/helpers/date/is-on-same-day/index.js +13 -0
- package/helpers/date/is-on-same-day/index.test.js +59 -0
- package/helpers/date/is-on-same-year/README.md +13 -0
- package/helpers/date/is-on-same-year/index.js +11 -0
- package/helpers/date/is-on-same-year/index.test.js +21 -0
- package/helpers/date/is-on-same-year/package.json +25 -0
- package/package.json +29 -0
- package/vitest.config.ts +12 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
|
+
|
5
|
+
### [0.0.2](https://github.com/ismailceylan/mark-3/compare/v0.0.1...v0.0.2) (2025-08-01)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* **helpers:** add new date/format helper ([9d2eb12](https://github.com/ismailceylan/mark-3/commit/9d2eb12c8595785d0b40ec740612ecdc407e4fe2))
|
11
|
+
* **helpers:** add new date/from-timestamp helper ([812163f](https://github.com/ismailceylan/mark-3/commit/812163f84a11e53f77b7f291ccad8f1b3bd88631))
|
12
|
+
* **helpers:** add new date/is-on-same-day helper ([8fe86fc](https://github.com/ismailceylan/mark-3/commit/8fe86fcff57d51803307f12f7e78310999f0acb2))
|
13
|
+
* **helpers:** add new date/is-on-same-year helper ([f29123a](https://github.com/ismailceylan/mark-3/commit/f29123a2997e294c2672bb450124e0b571b6d730))
|
14
|
+
|
15
|
+
### 0.0.1 (2025-08-01)
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 İsmail Ceylan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# format
|
2
|
+
A lightweight and flexible date formatting utility for JavaScript and TypeScript. This helper formats Date objects using PHP-style tokens like Y, m, d, H, i, and more. It supports both short and long month names with locale-aware formatting via Intl.DateTimeFormat.
|
3
|
+
|
4
|
+
Built with simplicity and clarity in mind — no external dependencies, easy to use, fully typed.
|
5
|
+
|
6
|
+
---
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
```ts
|
10
|
+
import { format } from '@mark-3/helpers/date';
|
11
|
+
|
12
|
+
format( new Date, "Y-m-d H:i:s" );
|
13
|
+
// 2022-01-01 22:00:00 (mysql datetime format)
|
14
|
+
|
15
|
+
format( new Date, "j MM, H:i", "tr" );
|
16
|
+
// 1 Temmuz, 22:00
|
17
|
+
```
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
## 💡 Supported Tokens
|
22
|
+
`d`: 01-31 (zero-padded day)
|
23
|
+
`j`: 1-31 (non-padded day)
|
24
|
+
`m`: 01-12 (zero-padded month)
|
25
|
+
`n`: 1-12 (non-padded month)
|
26
|
+
`M`: Jan–Dec (short month name, localized)
|
27
|
+
`MM`: January–December (long month name, localized)
|
28
|
+
`y`: 00-99 (two-digit year)
|
29
|
+
`Y`: 0000-9999 (full year)
|
30
|
+
`H`: 00-23 (zero-padded hour, 24h)
|
31
|
+
`G`: 0-23 (hour, 24h)
|
32
|
+
`i`: 00-59 (minutes)
|
33
|
+
`s`: 00-59 (seconds)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
* Format a date according to a given pattern.
|
3
|
+
*
|
4
|
+
* @param {Date} date The date to format.
|
5
|
+
* @param {string} pattern The pattern to use for formatting the date.
|
6
|
+
* @param {string} [lang="en"] The language to use for month names.
|
7
|
+
* @returns {string} The formatted date string.
|
8
|
+
*
|
9
|
+
* Supported patterns:
|
10
|
+
*
|
11
|
+
* - d: 01-31 (zero-padded day of the month)
|
12
|
+
* - j: 1-31 (day of the month)
|
13
|
+
* - m: 01-12 (zero-padded month)
|
14
|
+
* - n: 1-12 (month)
|
15
|
+
* - M: January-December (month name, localized for the given language)
|
16
|
+
* - y: 00-99 (2-digit year)
|
17
|
+
* - Y: 0000-9999 (4-digit year)
|
18
|
+
* - H: 00-23 (zero-padded hour in 24-hour format)
|
19
|
+
* - G: 0-23 (hour in 24-hour format)
|
20
|
+
* - i: 00-59 (zero-padded minute)
|
21
|
+
* - s: 00-59 (zero-padded second)
|
22
|
+
*/
|
23
|
+
export default function formatDate( date, pattern, lang = "en" )
|
24
|
+
{
|
25
|
+
function pad( n, len = 2 )
|
26
|
+
{
|
27
|
+
return n.toString().padStart( len, "0" );
|
28
|
+
}
|
29
|
+
|
30
|
+
const replacements =
|
31
|
+
{
|
32
|
+
// Day
|
33
|
+
d: pad( date.getDate()), // 01-31
|
34
|
+
j: date.getDate().toString(), // 1-31
|
35
|
+
|
36
|
+
// Month
|
37
|
+
m: pad( date.getMonth() + 1 ), // 01-12
|
38
|
+
n: ( date.getMonth() + 1 ).toString(), // 1-12
|
39
|
+
M: new Intl.DateTimeFormat( lang, { month: "short" }).format( date ),
|
40
|
+
MM: new Intl.DateTimeFormat( lang, { month: "long" }).format( date ),
|
41
|
+
|
42
|
+
// Year
|
43
|
+
y: date.getFullYear().toString().slice( -2 ), // 2 digit year
|
44
|
+
Y: date.getFullYear().toString(), // 4 digit year
|
45
|
+
|
46
|
+
// Hour
|
47
|
+
H: pad( date.getHours()), // 00-23
|
48
|
+
G: date.getHours().toString(), // 0-23
|
49
|
+
|
50
|
+
// Minute
|
51
|
+
i: pad( date.getMinutes()), // 00-59
|
52
|
+
|
53
|
+
// Second
|
54
|
+
s: pad( date.getSeconds()), // 00-59
|
55
|
+
}
|
56
|
+
|
57
|
+
return pattern.replace( /d|j|m|n|MM|M|y|Y|H|G|i|s/g, match =>
|
58
|
+
replacements[ match ]
|
59
|
+
);
|
60
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import formatDate from "./index";
|
3
|
+
|
4
|
+
describe( "formatDate", () =>
|
5
|
+
{
|
6
|
+
const date = new Date( "2025-12-21T22:10:05" );
|
7
|
+
|
8
|
+
it( "formats full year (Y)", () =>
|
9
|
+
{
|
10
|
+
expect( formatDate( date, "Y" )).toBe( "2025" );
|
11
|
+
});
|
12
|
+
|
13
|
+
it( "formats short year (y)", () =>
|
14
|
+
{
|
15
|
+
expect( formatDate( date, "y" )).toBe( "25" );
|
16
|
+
});
|
17
|
+
|
18
|
+
it( "formats zero-padded month (m)", () =>
|
19
|
+
{
|
20
|
+
expect( formatDate( date, "m" )).toBe( "12" );
|
21
|
+
});
|
22
|
+
|
23
|
+
it( "formats non-padded month (n)", () =>
|
24
|
+
{
|
25
|
+
expect( formatDate( date, "n" )).toBe( "12" );
|
26
|
+
});
|
27
|
+
|
28
|
+
it( "formats short month name (M)", () =>
|
29
|
+
{
|
30
|
+
expect( formatDate( date, "M" )).toBe( "Dec" );
|
31
|
+
});
|
32
|
+
|
33
|
+
it( "formats full month name (MM)", () =>
|
34
|
+
{
|
35
|
+
expect( formatDate( date, "MM" )).toBe( "December" );
|
36
|
+
});
|
37
|
+
|
38
|
+
it( "formats day padded (d)", () =>
|
39
|
+
{
|
40
|
+
expect( formatDate( date, "d" )).toBe( "21" );
|
41
|
+
});
|
42
|
+
|
43
|
+
it( "formats day non-padded (j)", () =>
|
44
|
+
{
|
45
|
+
expect( formatDate( date, "j" )).toBe( "21" );
|
46
|
+
});
|
47
|
+
|
48
|
+
it( "formats zero-padded hour (H)", () =>
|
49
|
+
{
|
50
|
+
expect( formatDate( date, "H" )).toBe( "22" );
|
51
|
+
});
|
52
|
+
|
53
|
+
it( "formats non-padded hour (G)", () =>
|
54
|
+
{
|
55
|
+
expect( formatDate( date, "G" )).toBe( "22" );
|
56
|
+
});
|
57
|
+
|
58
|
+
it( "formats minutes (i)", () =>
|
59
|
+
{
|
60
|
+
expect( formatDate( date, "i" )).toBe( "10" );
|
61
|
+
});
|
62
|
+
|
63
|
+
it( "formats seconds (s)", () =>
|
64
|
+
{
|
65
|
+
expect( formatDate( date, "s" )).toBe( "05" );
|
66
|
+
});
|
67
|
+
|
68
|
+
it( "formats a custom pattern", () =>
|
69
|
+
{
|
70
|
+
expect( formatDate( date, "d.m.Y H:i" )).toBe( "21.12.2025 22:10" );
|
71
|
+
});
|
72
|
+
|
73
|
+
it( "supports localized short month (M) in TR", () =>
|
74
|
+
{
|
75
|
+
expect( formatDate( date, "M", "tr" )).toBe( "Ara" ); // Aralık
|
76
|
+
});
|
77
|
+
|
78
|
+
it( "supports localized long month (MM) in TR", () =>
|
79
|
+
{
|
80
|
+
expect( formatDate( date, "MM", "tr" )).toBe( "Aralık" );
|
81
|
+
});
|
82
|
+
|
83
|
+
it( "returns empty string for empty pattern", () =>
|
84
|
+
{
|
85
|
+
expect( formatDate( date, "" )).toBe( "" );
|
86
|
+
});
|
87
|
+
|
88
|
+
it( "leaves unknown tokens as-is", () =>
|
89
|
+
{
|
90
|
+
expect( formatDate( date, "[foo] Y" )).toBe( "[foo] 2025" );
|
91
|
+
});
|
92
|
+
|
93
|
+
it( "mixes plain text and tokens", () =>
|
94
|
+
{
|
95
|
+
expect( formatDate( date, "d MM Y, H:i" )).toBe( "21 December 2025, 22:10" );
|
96
|
+
});
|
97
|
+
});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# fromTimestamp
|
2
|
+
This function handles both seconds and milliseconds timestamps by checking the length of the number.
|
3
|
+
|
4
|
+
If the `timestamp` is less than `1e11`, it's assumed to be in seconds and is converted to milliseconds. If the conversion results in an invalid `Date` object, the function returns the provided `defaultValue`
|
5
|
+
or `undefined` if no default is specified.
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
```ts
|
11
|
+
import fromTimestamp from '@mark-3/helpers-date-from-timestamp';
|
12
|
+
|
13
|
+
const result = fromTimestamp( 1753634780845 );
|
14
|
+
```
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* Converts a Unix timestamp to a JavaScript Date object.
|
3
|
+
*
|
4
|
+
* @template T
|
5
|
+
* @param {number|string} timestamp - The Unix timestamp in seconds or milliseconds, or a string that can be converted to a number.
|
6
|
+
* @param {T} [defaultValue] - The value to return if timestamp is invalid or results in an invalid Date.
|
7
|
+
* @returns {Date|T|undefined} A Date object representing the timestamp, or the defaultValue if the timestamp is invalid.
|
8
|
+
*
|
9
|
+
* This function handles both seconds and milliseconds timestamps by checking the length of the number.
|
10
|
+
* If the timestamp is less than 1e11, it's assumed to be in seconds and is converted to milliseconds.
|
11
|
+
* If the conversion results in an invalid Date object, the function returns the provided defaultValue
|
12
|
+
* or undefined if no default is specified.
|
13
|
+
*/
|
14
|
+
export default function fromTimestamp( timestamp, defaultValue )
|
15
|
+
{
|
16
|
+
const ts = typeof timestamp === "string"
|
17
|
+
? Number( timestamp )
|
18
|
+
: timestamp;
|
19
|
+
|
20
|
+
if( Number.isNaN( ts ))
|
21
|
+
{
|
22
|
+
return defaultValue;
|
23
|
+
}
|
24
|
+
|
25
|
+
const time = ts < 1e11
|
26
|
+
? ts * 1000
|
27
|
+
: ts;
|
28
|
+
|
29
|
+
const date = new Date( time );
|
30
|
+
|
31
|
+
return isNaN( date.getTime())
|
32
|
+
? defaultValue
|
33
|
+
: date;
|
34
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import fromTimestamp from "./index";
|
3
|
+
|
4
|
+
describe( "fromTimestamp", () =>
|
5
|
+
{
|
6
|
+
it( "should parse milliseconds timestamp correctly", () =>
|
7
|
+
{
|
8
|
+
const now = Date.now();
|
9
|
+
const result = fromTimestamp( now );
|
10
|
+
|
11
|
+
expect( result ).toBeInstanceOf( Date );
|
12
|
+
expect( result?.getTime()).toBe( now );
|
13
|
+
});
|
14
|
+
|
15
|
+
it( "should parse seconds timestamp correctly", () =>
|
16
|
+
{
|
17
|
+
const now = Math.floor( Date.now() / 1000 );
|
18
|
+
const result = fromTimestamp( now );
|
19
|
+
|
20
|
+
expect( result ).toBeInstanceOf( Date );
|
21
|
+
expect( Math.floor( result?.getTime() / 1000 )).toBe( now );
|
22
|
+
});
|
23
|
+
|
24
|
+
it( "should return defaultValue for non-number input", () =>
|
25
|
+
{
|
26
|
+
const result = fromTimestamp( "not-a-number", "default" );
|
27
|
+
expect( result ).toBe( "default" );
|
28
|
+
});
|
29
|
+
|
30
|
+
it( "should return defaultValue for NaN date", () =>
|
31
|
+
{
|
32
|
+
const result = fromTimestamp( NaN, "fallback" );
|
33
|
+
expect( result ).toBe( "fallback" );
|
34
|
+
});
|
35
|
+
|
36
|
+
it( "should return undefined for invalid input without default", () =>
|
37
|
+
{
|
38
|
+
expect( fromTimestamp( NaN )).toBeUndefined();
|
39
|
+
});
|
40
|
+
|
41
|
+
it( "should support boolean as default value", () =>
|
42
|
+
{
|
43
|
+
const result = fromTimestamp( NaN, false );
|
44
|
+
expect( result ).toBe( false );
|
45
|
+
});
|
46
|
+
|
47
|
+
it( "should support object as default value", () =>
|
48
|
+
{
|
49
|
+
const fallback = { error: true }
|
50
|
+
const result = fromTimestamp( NaN, fallback );
|
51
|
+
|
52
|
+
expect( result ).toBe( fallback );
|
53
|
+
});
|
54
|
+
|
55
|
+
it( "should return defaultValue for Infinity", () =>
|
56
|
+
{
|
57
|
+
expect( fromTimestamp( Infinity, "fallback" )).toBe( "fallback" );
|
58
|
+
});
|
59
|
+
|
60
|
+
it( "should return undefined for Infinity without defaultValue", () =>
|
61
|
+
{
|
62
|
+
expect( fromTimestamp( Infinity )).toBe( undefined );
|
63
|
+
});
|
64
|
+
});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# isOnSameDay
|
2
|
+
A lightweight utility to check whether two JavaScript `Date` objects are in the same calendar day.
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
```ts
|
8
|
+
import isOnSameDay from '@mark-3/helpers-date-is-on-same-day';
|
9
|
+
|
10
|
+
const result = isOnSameDay( new Date( '2022-01-01' ), new Date( '2022-12-31' ));
|
11
|
+
// false
|
12
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Checks if two Date objects fall within the same day of the year.
|
3
|
+
*
|
4
|
+
* @param {Date} dateA The first date.
|
5
|
+
* @param {Date} dateB The second date.
|
6
|
+
* @returns {boolean} True if both dates fall within the same day of the year, otherwise false.
|
7
|
+
*/
|
8
|
+
export default function isOnSameYear( dateA, dateB )
|
9
|
+
{
|
10
|
+
return dateA.getUTCDate() === dateB.getUTCDate() &&
|
11
|
+
dateA.getUTCMonth() === dateB.getUTCMonth() &&
|
12
|
+
dateA.getUTCFullYear() === dateB.getUTCFullYear();
|
13
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import isOnSameDay from "./index";
|
3
|
+
|
4
|
+
describe( "isOnSameDay", () =>
|
5
|
+
{
|
6
|
+
it( "returns true for same year, month and day", () =>
|
7
|
+
{
|
8
|
+
const d1 = new Date( "2023-07-27T10:00:00" );
|
9
|
+
const d2 = new Date( "2023-07-27T23:59:59" );
|
10
|
+
|
11
|
+
expect( isOnSameDay( d1, d2 )).toBe( true );
|
12
|
+
});
|
13
|
+
|
14
|
+
it( "returns false for same month and day but different year", () =>
|
15
|
+
{
|
16
|
+
const d1 = new Date( "2022-07-27" );
|
17
|
+
const d2 = new Date( "2023-07-27" );
|
18
|
+
|
19
|
+
expect( isOnSameDay( d1, d2 )).toBe( false );
|
20
|
+
});
|
21
|
+
|
22
|
+
it( "returns false for same year and day but different month", () =>
|
23
|
+
{
|
24
|
+
const d1 = new Date( "2023-06-27" );
|
25
|
+
const d2 = new Date( "2023-07-27" );
|
26
|
+
|
27
|
+
expect( isOnSameDay( d1, d2 )).toBe( false );
|
28
|
+
});
|
29
|
+
|
30
|
+
it( "returns false for same year and month but different day", () =>
|
31
|
+
{
|
32
|
+
const d1 = new Date( "2023-07-26" );
|
33
|
+
const d2 = new Date( "2023-07-27" );
|
34
|
+
|
35
|
+
expect( isOnSameDay( d1, d2 )).toBe( false );
|
36
|
+
});
|
37
|
+
|
38
|
+
it( "returns true for exact same date object", () =>
|
39
|
+
{
|
40
|
+
const d1 = new Date( "2023-07-27T12:34:56" );
|
41
|
+
expect( isOnSameDay( d1, d1 )).toBe( true );
|
42
|
+
});
|
43
|
+
|
44
|
+
it( "works correctly across timezones if both dates are created equally", () =>
|
45
|
+
{
|
46
|
+
const d1 = new Date( Date.UTC( 2023, 6, 27, 0, 0, 0 )); // UTC
|
47
|
+
const d2 = new Date( Date.UTC( 2023, 6, 27, 23, 59, 59 ));
|
48
|
+
|
49
|
+
expect( isOnSameDay( d1, d2 )).toBe( true );
|
50
|
+
});
|
51
|
+
|
52
|
+
it( "returns false for completely different dates", () =>
|
53
|
+
{
|
54
|
+
const d1 = new Date( "1999-01-01" );
|
55
|
+
const d2 = new Date( "2025-12-31" );
|
56
|
+
|
57
|
+
expect( isOnSameDay( d1, d2 )).toBe( false );
|
58
|
+
});
|
59
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# isOnSameYear
|
2
|
+
A lightweight utility to check whether two JavaScript `Date` objects are in the same calendar year.
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
```ts
|
9
|
+
import isOnSameYear from '@mark-3/helpers-date-is-on-same-year';
|
10
|
+
|
11
|
+
const result = isOnSameYear( new Date( '2022-01-01' ), new Date( '2022-12-31' ));
|
12
|
+
// true
|
13
|
+
```
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* Checks if two Date objects fall within the same year.
|
3
|
+
*
|
4
|
+
* @param {Date} dateA The first date.
|
5
|
+
* @param {Date} dateB The second date.
|
6
|
+
* @returns {boolean} True if both dates fall within the same year, otherwise false.
|
7
|
+
*/
|
8
|
+
export default function isOnSameYear( dateA, dateB )
|
9
|
+
{
|
10
|
+
return dateA.getFullYear() === dateB.getFullYear();
|
11
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import isOnSameYear from "./index";
|
3
|
+
|
4
|
+
describe( "isOnSameYear", () =>
|
5
|
+
{
|
6
|
+
it( "returns true if both dates are in the same year", () =>
|
7
|
+
{
|
8
|
+
const date1 = new Date( "2023-01-01" );
|
9
|
+
const date2 = new Date( "2023-12-31" );
|
10
|
+
|
11
|
+
expect( isOnSameYear( date1, date2 )).toBe( true );
|
12
|
+
});
|
13
|
+
|
14
|
+
it( "returns false if years differ", () =>
|
15
|
+
{
|
16
|
+
const date1 = new Date( "2022-12-31" );
|
17
|
+
const date2 = new Date( "2023-01-01" );
|
18
|
+
|
19
|
+
expect( isOnSameYear( date1, date2 )).toBe( false );
|
20
|
+
});
|
21
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"name": "@mark-3/helpers-date-is-on-same-year",
|
3
|
+
"type": "module",
|
4
|
+
"version": "0.0.3",
|
5
|
+
"description": "Checks if two Date objects fall within the same year.",
|
6
|
+
"main": "dist/index.js",
|
7
|
+
"types": "dist/index.d.ts",
|
8
|
+
"scripts": {
|
9
|
+
"build": "tsc",
|
10
|
+
"release": "standard-version",
|
11
|
+
"publish-package": "npm publish --access=public"
|
12
|
+
},
|
13
|
+
"standard-version": {
|
14
|
+
"tagPrefix": "@mark-3/helpers/date/is-on-same-year@"
|
15
|
+
},
|
16
|
+
"keywords": [
|
17
|
+
"date",
|
18
|
+
"helper",
|
19
|
+
"year",
|
20
|
+
"compare",
|
21
|
+
"utility"
|
22
|
+
],
|
23
|
+
"author": "Ismail Ceylan",
|
24
|
+
"license": "MIT"
|
25
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"name": "mark-3",
|
3
|
+
"description": "Modular collection of reusable JavaScript helpers, utilities, and Vue components. Built for maintainability, performance, and clarity.",
|
4
|
+
"private": false,
|
5
|
+
"version": "0.0.2",
|
6
|
+
"workspaces": [
|
7
|
+
"src/*/*"
|
8
|
+
],
|
9
|
+
"scripts": {
|
10
|
+
"release": "standard-version",
|
11
|
+
"test": "npx vitest --ui --coverage",
|
12
|
+
"publish-package": "npm publish --access=public"
|
13
|
+
},
|
14
|
+
"standard-version": {},
|
15
|
+
"author": {
|
16
|
+
"name": "Ismail Ceylan",
|
17
|
+
"email": "ismaillceylan@gmail.com"
|
18
|
+
},
|
19
|
+
"repository": {
|
20
|
+
"type": "git",
|
21
|
+
"url": "git+https://github.com/ismailceylan/mark-3.git"
|
22
|
+
},
|
23
|
+
"license": "MIT",
|
24
|
+
"devDependencies": {
|
25
|
+
"@vitest/coverage-v8": "^3.2.4",
|
26
|
+
"@vitest/ui": "^3.2.4",
|
27
|
+
"vitest": "^3.2.4"
|
28
|
+
}
|
29
|
+
}
|