easter-date.js 0.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/LICENSE +19 -0
- package/README.md +80 -0
- package/lib/easter-date.cjs +1 -0
- package/lib/easter-date.js +1 -0
- package/package.json +43 -0
- package/src/types/types.d.ts +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2022 by 42proger
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Easter Date Calculation
|
|
2
|
+
|
|
3
|
+
This project provides two algorithms for calculating the date of Easter in the Western (Catholic and Protestant) and Orthodox calendars.
|
|
4
|
+
|
|
5
|
+
Based on Gauss's Easter algorithm:
|
|
6
|
+
https://doi.org/10.1007/s00407-004-0078-5
|
|
7
|
+
|
|
8
|
+
## Installing
|
|
9
|
+
|
|
10
|
+
Install with npm
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install easter-date.js
|
|
14
|
+
```
|
|
15
|
+
or yarn:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add easter-date.js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage/Examples
|
|
22
|
+
|
|
23
|
+
To use the algorithms, import them into your JavaScript code:
|
|
24
|
+
```javascript
|
|
25
|
+
// ES Modules
|
|
26
|
+
import { getWesternEaster, getOrthodoxEaster } from "easter-date.js";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
// CommonJS
|
|
31
|
+
const { getWesternEaster, getOrthodoxEaster } = require('easter-date.js');
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
and pass the desired year as an argument:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
getWesternEaster(2024);
|
|
38
|
+
// Output: { day: 31, month: 3, year: 2024 }
|
|
39
|
+
|
|
40
|
+
getOrthodoxEaster(2024);
|
|
41
|
+
// Output: { day: 5, month: 5, year: 2024 }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Run Locally
|
|
45
|
+
|
|
46
|
+
Clone the project
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/42proger/easter-date.js
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Go to the project directory
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd easter-date.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Install dependencies
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Run a compile
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Running Tests
|
|
71
|
+
|
|
72
|
+
To run the tests, install the required dependencies and run the following command:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run test
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
[MIT](https://opensource.org/licenses/MIT)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function u(t){const c=t%19,f=t%4,h=t%7,e=(19*c+15)%30,d=(2*f+4*h+6*e+6)%7,o=e+d,n=o<=26?4:5;return{day:o<=26?o+4:o-26,month:n,year:t}}function g(t){const c=t%19,f=t%4,h=t%7,e=Math.floor(t/100),d=Math.floor((13+8*e)/25),o=Math.floor(e/4),n=(15-d+e-o)%30,M=(4+e-o)%7,s=(19*c+n)%30,r=(2*f+4*h+6*s+M)%7,l=s+r+22,i=l<=31?3:4;let a;return s===29&&r===6?a=19:s===28&&r===6&&(11*n+11)%30<19?a=18:a=l<=31?l:s+r-9,{day:a,month:i,year:t}}exports.getOrthodoxEaster=u,exports.getWesternEaster=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function u(t){const c=t%19,f=t%4,h=t%7,o=(19*c+15)%30,l=(2*f+4*h+6*o+6)%7,e=o+l,s=e<=26?4:5;return{day:e<=26?e+4:e-26,month:s,year:t}}function D(t){const c=t%19,f=t%4,h=t%7,o=Math.floor(t/100),l=Math.floor((13+8*o)/25),e=Math.floor(o/4),s=(15-l+o-e)%30,d=(4+o-e)%7,n=(19*c+s)%30,a=(2*f+4*h+6*n+d)%7,M=n+a+22,i=M<=31?3:4;let r;return n===29&&a===6?r=19:n===28&&a===6&&(11*s+11)%30<19?r=18:r=M<=31?M:n+a-9,{day:r,month:i,year:t}}export{u as getOrthodoxEaster,D as getWesternEaster};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "easter-date.js",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "This JavaScript function calculates the Easter date in the Western and Orthodox calendars using Gauss's Easter algorithm. It takes a year as an argument and returns the Easter date in the specified year. The algorithm was developed by Carl Friedrich Gauss and allows the date of Easter to be determined in both the Catholic/Protestant and Orthodox calendars.",
|
|
5
|
+
"author": "42proger",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/42proger/easter-date.js/issues"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/42proger/easter-date.js#readme",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"easter",
|
|
13
|
+
"date",
|
|
14
|
+
"algorithm",
|
|
15
|
+
"gauss",
|
|
16
|
+
"calendar"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./lib/easter-date.cjs",
|
|
20
|
+
"module": "./lib/easter-date.js",
|
|
21
|
+
"types": "./src/types/types.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./lib/easter-date.cjs",
|
|
25
|
+
"import": "./lib/easter-date.js",
|
|
26
|
+
"types": "./src/types/types.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "rollup -c",
|
|
31
|
+
"test": "jest"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"rollup": "^4.17.2",
|
|
38
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
39
|
+
"ts-jest": "^29.1.2",
|
|
40
|
+
"tslib": "^2.6.2",
|
|
41
|
+
"typescript": "^5.4.5"
|
|
42
|
+
}
|
|
43
|
+
}
|