natural-time-js 1.1.1 → 2.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 +27 -0
- package/README.md +99 -107
- package/babel.config.cjs +9 -0
- package/dist/astronomy/celestial.d.ts +104 -0
- package/{context.js → dist/astronomy/celestial.js} +99 -176
- package/dist/astronomy/celestial.js.map +1 -0
- package/dist/core/NaturalDate.d.ts +164 -0
- package/dist/core/NaturalDate.js +254 -0
- package/dist/core/NaturalDate.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +118 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/validators.d.ts +140 -0
- package/dist/utils/validators.js +231 -0
- package/dist/utils/validators.js.map +1 -0
- package/jest.config.cjs +29 -0
- package/package.json +23 -3
- package/.github/natural-time-app.jpg +0 -0
- package/index.js +0 -241
- package/utils/validators.js +0 -136
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.1] - 2024-03-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed Southern hemisphere mustache angle calculations
|
|
12
|
+
- Added .npmignore file for better package distribution
|
|
13
|
+
|
|
14
|
+
## [2.0.0]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Switch to typescript
|
|
18
|
+
- Documentation with JSDoc
|
|
19
|
+
- Complete suite of test files with JEST
|
|
20
|
+
- Reorganize files structure (breaking changes)
|
|
21
|
+
|
|
22
|
+
## [1.1.1]
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Initial public release with basic functionality
|
|
26
|
+
- Core natural time calculations
|
|
27
|
+
- Basic formatting options
|
package/README.md
CHANGED
|
@@ -1,161 +1,153 @@
|
|
|
1
|
-
# Natural
|
|
1
|
+
# Natural Time JS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A revolutionary approach to time measurement, realigning human experience with nature's rhythms.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## The Natural Time Paradigm
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Play with natural time at [https://naturaltime.app/](https://naturaltime.app/)
|
|
10
|
-
|
|
11
|
-
### JavaScript library
|
|
7
|
+
Our current time system - the Gregorian calendar with its arbitrary months and 24-hour days - is a human construct disconnected from natural cycles. Natural Time proposes a return to cosmic truth:
|
|
12
8
|
|
|
13
|
-
This repository contains the JavaScript implementation of natural time.
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
- **Circular Time**: Days measured in 360 degrees, following the sun's continuous journey
|
|
11
|
+
- **Location-Aware**: Time calculations adjusted to your longitude, acknowledging Earth's rotation
|
|
12
|
+
- **Solar-Anchored Years**: Each year begins at winter solstice, nature's true new year marker
|
|
13
|
+
- **13 Perfect Moons**: 28-day cycles matching the moon's natural rhythm (364 days)
|
|
14
|
+
- **Rainbow Days**: 1-2 days outside the count to honor year completion and solar alignment
|
|
17
15
|
|
|
18
|
-
### Natural time specifications
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
This isn't just a calendar reform - it's a return to measuring time through observable celestial events that have guided humanity for millennia.
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
## Try Natural Time
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
🌟 **Experience it yourself!** The best way to understand Natural Time is to try it:
|
|
25
22
|
|
|
26
|
-
You can play with natural time at [https://naturaltime.app/](https://naturaltime.app/). It both works online and offline thanks to this JavaScript library.
|
|
27
23
|
|
|
28
24
|

|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
- **Web App**: Visit [naturaltime.app](https://naturaltime.app/) to see it in action
|
|
27
|
+
- **Source Code**: Explore the app's implementation at [github.com/sylvain441/natural-time-app](https://github.com/sylvain441/natural-time-app)
|
|
28
|
+
- **Features**:
|
|
29
|
+
- Works offline
|
|
30
|
+
- Location-aware time calculations
|
|
31
|
+
- Beautiful visualization of natural cycles
|
|
32
|
+
- Powered by this JavaScript library
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Instalation
|
|
35
|
-
|
|
36
|
-
Install NPM package with your terminal:
|
|
34
|
+
## Installation
|
|
37
35
|
|
|
38
36
|
```console
|
|
39
37
|
npm install natural-time-js
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
##
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### NaturalDate Class
|
|
43
43
|
|
|
44
|
-
The
|
|
44
|
+
The core class for working with Natural Time:
|
|
45
45
|
|
|
46
46
|
```javascript
|
|
47
47
|
import { NaturalDate } from 'natural-time-js';
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
let naturalDate = new NaturalDate(artificialDate, longitude);
|
|
49
|
+
// Convert current time at longitude 5.2° E
|
|
50
|
+
const naturalDate = new NaturalDate(new Date(), 5.2);
|
|
51
|
+
console.log(naturalDate.toString()); // "004)04)01 113°00 NT+5.2"
|
|
53
52
|
```
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
#### Properties
|
|
56
55
|
|
|
57
56
|
```javascript
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
57
|
+
// Time Properties
|
|
58
|
+
naturalDate.unixTime; // Artificial gregorian date (UNIX timestamp)
|
|
59
|
+
naturalDate.time; // Current time in degrees (0-359.999...)
|
|
60
|
+
naturalDate.nadir; // Beginning of the day at current longitude (UNIX timestamp)
|
|
61
|
+
|
|
62
|
+
// Location
|
|
63
|
+
naturalDate.longitude; // Longitude (-180° to +180°)
|
|
64
|
+
|
|
65
|
+
// Year Properties
|
|
66
|
+
naturalDate.year; // Current year (year 1: 2012/2013)
|
|
67
|
+
naturalDate.yearStart; // Beginning of the year at current longitude (UNIX timestamp)
|
|
68
|
+
naturalDate.yearDuration;// Days in current year (365 or 366)
|
|
69
|
+
naturalDate.dayOfYear; // Current day of the year (1-366)
|
|
70
|
+
|
|
71
|
+
// Moon Properties
|
|
72
|
+
naturalDate.moon; // Current moon (1-13, or 14 for rainbow days)
|
|
73
|
+
naturalDate.dayOfMoon; // Current day of the moon (1-28)
|
|
74
|
+
naturalDate.weekOfMoon; // Current week of the moon (1-4)
|
|
75
|
+
|
|
76
|
+
// Week Properties
|
|
77
|
+
naturalDate.week; // Current week (1-53)
|
|
78
|
+
naturalDate.dayOfWeek; // Current day of the week (1-7)
|
|
79
|
+
|
|
80
|
+
// Special Properties
|
|
81
|
+
naturalDate.isRainbowDay;// True if current day is rainbow day
|
|
82
|
+
naturalDate.day; // Days since END_OF_ARTIFICIAL_TIME
|
|
83
|
+
|
|
84
|
+
// Constants
|
|
85
|
+
NaturalDate.END_OF_ARTIFICIAL_TIME; // 1356091200000 (2012-12-21 12:00:00 UTC)
|
|
86
|
+
NaturalDate.MILLISECONDS_PER_DAY; // 86400000 (24*60*60*1000)
|
|
82
87
|
```
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
#### Utility Methods
|
|
85
90
|
|
|
86
|
-
```javascript
|
|
87
|
-
naturalDate.toString()
|
|
88
|
-
naturalDate.toDateString(
|
|
89
|
-
naturalDate.toTimeString(
|
|
90
|
-
naturalDate.toLongitudeString(
|
|
91
|
-
naturalDate.toYearString()
|
|
92
|
-
naturalDate.toMoonString()
|
|
93
|
-
naturalDate.toDayOfMoonString()
|
|
91
|
+
```javascript
|
|
92
|
+
naturalDate.toString(); // "004)04)01 113°00 NT+5.2"
|
|
93
|
+
naturalDate.toDateString(); // "004)04)01"
|
|
94
|
+
naturalDate.toTimeString(); // "113°00"
|
|
95
|
+
naturalDate.toLongitudeString(); // "NT+5.2"
|
|
96
|
+
naturalDate.toYearString(); // "004"
|
|
97
|
+
naturalDate.toMoonString(); // "04"
|
|
98
|
+
naturalDate.toDayOfMoonString(); // "01"
|
|
94
99
|
```
|
|
95
100
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
## `NaturalDateContext` functions
|
|
99
|
-
|
|
100
|
-
The NaturalDateContext.js file contains utility functions to bring some astronomical context to the natural date (ex: altitude of the sun, phase of the moon).
|
|
101
|
-
|
|
102
|
-
```javascript
|
|
103
|
-
import { NaturalSunAltitude, NaturalSunEvents, NaturalMoonPosition, NaturalMoonEvents } from 'natural-time-js/context';
|
|
101
|
+
### Astronomical Functions
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
let latitude: 29.9791;
|
|
107
|
-
let longitude: 31.1341;
|
|
103
|
+
Calculate precise celestial events and positions:
|
|
108
104
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
|
|
105
|
+
```javascript
|
|
106
|
+
import { NaturalSunEvents, NaturalMoonPosition } from 'natural-time-js';
|
|
107
|
+
|
|
108
|
+
// Giza Pyramid coordinates
|
|
109
|
+
const latitude = 29.9791;
|
|
110
|
+
const longitude = 31.1341;
|
|
111
|
+
const naturalDate = new NaturalDate(new Date(), longitude);
|
|
112
|
+
|
|
113
|
+
// Get sun events for the day
|
|
114
|
+
const sunEvents = NaturalSunEvents(naturalDate, latitude);
|
|
115
|
+
console.log(sunEvents.sunrise); // 70.567° (time in natural degrees)
|
|
116
|
+
console.log(sunEvents.sunset); // 287.910°
|
|
117
|
+
|
|
118
|
+
// Get current moon position and phase
|
|
119
|
+
const moonInfo = NaturalMoonPosition(naturalDate, latitude);
|
|
120
|
+
console.log(moonInfo.phase); // 74.861° (percentage of lunar cycle)
|
|
121
|
+
console.log(moonInfo.altitude); // 64.323° (degrees above horizon)
|
|
122
|
+
```
|
|
114
123
|
|
|
115
|
-
|
|
116
|
-
// sunrise: 70.56708493448893,
|
|
117
|
-
// sunset: 287.9105974344889,
|
|
118
|
-
// nightStart: 306.43507660115563,
|
|
119
|
-
// nightEnd: 52.13781826782227,
|
|
120
|
-
// morningGoldenHour: 80.8551891011556,
|
|
121
|
-
// eveningGoldenHour: 277.58920993448896
|
|
124
|
+
## Documentation
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
// phase: 74.86175469141531,
|
|
125
|
-
// altitude: 64.32391838504756,
|
|
126
|
-
// highestAltitude: 69.53997976716451
|
|
126
|
+
The library is fully documented using JSDoc. Generate the documentation with:
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// moonset: 10.624722434488932
|
|
128
|
+
```bash
|
|
129
|
+
npm run docs
|
|
131
130
|
```
|
|
132
131
|
|
|
133
|
-
|
|
134
|
-
Utility functions return time-distance from 0° or false if the event does not occur during this day (ex: no sunrise at the north pole during winter).
|
|
132
|
+
For live documentation updates during development:
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
```bash
|
|
135
|
+
npm run docs:dev
|
|
136
|
+
```
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
2. Add typescript compatibility
|
|
140
|
-
3. Make NaturalDate feel like the Javascript native Date Class by adding features like
|
|
141
|
-
- getTime()
|
|
142
|
-
- setMoon()
|
|
143
|
-
- ...
|
|
144
|
-
4. Make NaturalTime available for other programming languages
|
|
138
|
+
This creates HTML documentation in the `docs` directory.
|
|
145
139
|
|
|
146
|
-
|
|
140
|
+
## Contribute
|
|
147
141
|
|
|
148
142
|
Natural time is open to contributions from free-thinking minds. Find your way through Github or email at: [sylvain441@proton.me](mailto:sylvain441@proton.me) to get in touch.
|
|
149
143
|
|
|
150
|
-
|
|
144
|
+
## License
|
|
151
145
|
|
|
152
146
|
Read [full license](./LICENSE) (Creative Common Zero)
|
|
153
147
|
|
|
154
148
|
Natural time is completely free to use, play, transform, improve... It operates under the law of Love. Follow your heart, fork it, spoon it! There is no need to ask for permission to do anything with it.
|
|
155
149
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
# Acknowledgments
|
|
150
|
+
## Acknowledgments
|
|
159
151
|
|
|
160
152
|
Natural time has been baking for a long time in a goat's mind while traveling around the world. Infinite gratitude to my beloved friends Uncle Skywalker and Ik: your precious insights into the Mayan universe were so inspiring.
|
|
161
153
|
|
package/babel.config.cjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module natural-time-js/celestial
|
|
3
|
+
* @description The cosmic heartbeat of natural time - precise astronomical calculations that connect us to the rhythms of sun and moon.
|
|
4
|
+
*
|
|
5
|
+
* While artificial time ignores the sky, natural time is anchored to celestial reality.
|
|
6
|
+
* This module provides the astronomical foundation that makes natural time truly natural:
|
|
7
|
+
* - Exact solar positions throughout the day
|
|
8
|
+
* - Precise lunar phases and cycles
|
|
9
|
+
* - Solstice and equinox calculations
|
|
10
|
+
* - Location-aware sunrise, sunset, moonrise and moonset times
|
|
11
|
+
*/
|
|
12
|
+
import { NaturalDate } from '../core/NaturalDate';
|
|
13
|
+
/**
|
|
14
|
+
* Hemisphere identifiers for geographical calculations.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum HEMISPHERES {
|
|
17
|
+
/** Northern hemisphere (latitude >= 0) */
|
|
18
|
+
NORTH = "NORTH",
|
|
19
|
+
/** Southern hemisphere (latitude < 0) */
|
|
20
|
+
SOUTH = "SOUTH"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Day numbers marking the start and end of summer season.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SEASONS: {
|
|
26
|
+
/** Day 91 (typically April 1st) - Start of summer in Northern hemisphere */
|
|
27
|
+
readonly SUMMER_START_DAY: 91;
|
|
28
|
+
/** Day 273 (typically September 30th) - End of summer in Northern hemisphere */
|
|
29
|
+
readonly SUMMER_END_DAY: 273;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Solar altitude thresholds in degrees for different daylight conditions.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ANGLES: {
|
|
35
|
+
/** Altitude below which astronomical night begins (-12°) */
|
|
36
|
+
readonly NIGHT_ALTITUDE: -12;
|
|
37
|
+
/** Altitude below which golden hour lighting occurs (6°) */
|
|
38
|
+
readonly GOLDEN_HOUR_ALTITUDE: 6;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Interface for sun altitude information
|
|
42
|
+
*/
|
|
43
|
+
interface SunAltitude {
|
|
44
|
+
altitude: number;
|
|
45
|
+
highestAltitude: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Interface for sun events
|
|
49
|
+
*/
|
|
50
|
+
interface SunEvents {
|
|
51
|
+
sunrise: number;
|
|
52
|
+
sunset: number;
|
|
53
|
+
nightStart: number;
|
|
54
|
+
nightEnd: number;
|
|
55
|
+
morningGoldenHour: number;
|
|
56
|
+
eveningGoldenHour: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Interface for moon position information
|
|
60
|
+
*/
|
|
61
|
+
interface MoonPosition {
|
|
62
|
+
altitude: number;
|
|
63
|
+
phase: number;
|
|
64
|
+
illumination: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface for moon events
|
|
68
|
+
*/
|
|
69
|
+
interface MoonEvents {
|
|
70
|
+
moonrise: number;
|
|
71
|
+
moonset: number;
|
|
72
|
+
highestAltitude: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Interface for mustaches range information
|
|
76
|
+
*/
|
|
77
|
+
interface MustachesRange {
|
|
78
|
+
winterSunrise: number;
|
|
79
|
+
winterSunset: number;
|
|
80
|
+
summerSunrise: number;
|
|
81
|
+
summerSunset: number;
|
|
82
|
+
averageMustacheAngle: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Calculates the sun's altitude at a specific natural time and location.
|
|
86
|
+
*/
|
|
87
|
+
export declare function NaturalSunAltitude(naturalDate: NaturalDate, latitude: number): SunAltitude;
|
|
88
|
+
/**
|
|
89
|
+
* Calculates sun events for a specific natural date and location.
|
|
90
|
+
*/
|
|
91
|
+
export declare function NaturalSunEvents(naturalDate: NaturalDate, latitude: number): SunEvents;
|
|
92
|
+
/**
|
|
93
|
+
* Calculates the moon's position and phase.
|
|
94
|
+
*/
|
|
95
|
+
export declare function NaturalMoonPosition(naturalDate: NaturalDate, latitude: number): MoonPosition;
|
|
96
|
+
/**
|
|
97
|
+
* Calculates moon events for a specific natural date and location.
|
|
98
|
+
*/
|
|
99
|
+
export declare function NaturalMoonEvents(naturalDate: NaturalDate, latitude: number): MoonEvents;
|
|
100
|
+
/**
|
|
101
|
+
* Calculates the range of sun positions between winter and summer solstices (average mustaches angle)
|
|
102
|
+
*/
|
|
103
|
+
export declare function MustachesRange(naturalDate: NaturalDate, latitude: number): MustachesRange;
|
|
104
|
+
export {};
|