natural-time-js 2.0.6 → 3.0.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 +34 -29
- package/dist/NaturalDate.d.ts +61 -0
- package/dist/NaturalDate.js +138 -0
- package/dist/ephemeris.d.ts +47 -0
- package/dist/ephemeris.js +111 -0
- package/dist/index.d.ts +2 -80
- package/dist/index.js +3 -91
- package/package.json +3 -14
- package/dist/astronomy/celestial.d.ts +0 -108
- package/dist/astronomy/celestial.js +0 -244
- package/dist/astronomy/celestial.js.map +0 -1
- package/dist/core/NaturalDate.d.ts +0 -156
- package/dist/core/NaturalDate.js +0 -260
- package/dist/core/NaturalDate.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -118
- package/dist/types/index.js +0 -12
- package/dist/types/index.js.map +0 -1
- package/dist/utils/validators.d.ts +0 -140
- package/dist/utils/validators.js +0 -231
- package/dist/utils/validators.js.map +0 -1
package/dist/core/NaturalDate.js
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module natural-time-js/core
|
|
3
|
-
* @description This module provides the core NaturalDate class that bridges between artificial Gregorian time and Natural Time.
|
|
4
|
-
*/
|
|
5
|
-
import { Seasons } from 'astronomy-engine';
|
|
6
|
-
/**
|
|
7
|
-
* Cache for year context calculations to improve performance
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
const yearContextCache = new Map();
|
|
11
|
-
/**
|
|
12
|
-
* Calculates year context for natural date calculations.
|
|
13
|
-
*
|
|
14
|
-
* The year context includes:
|
|
15
|
-
* - The start timestamp of the natural year (winter solstice)
|
|
16
|
-
* - The duration of the year in days (365 or 366)
|
|
17
|
-
*
|
|
18
|
-
* This function handles the conversion between Gregorian calendar years
|
|
19
|
-
* and natural years, accounting for longitude adjustments.
|
|
20
|
-
*
|
|
21
|
-
* @param artificialYear - Gregorian calendar year
|
|
22
|
-
* @param longitude - Longitude in degrees (-180 to 180)
|
|
23
|
-
* @returns Year context object with start timestamp and duration
|
|
24
|
-
* @private
|
|
25
|
-
*/
|
|
26
|
-
const calculateYearContext = (artificialYear, longitude) => {
|
|
27
|
-
const cacheKey = `${artificialYear}_${longitude}`;
|
|
28
|
-
if (yearContextCache.has(cacheKey)) {
|
|
29
|
-
return yearContextCache.get(cacheKey);
|
|
30
|
-
}
|
|
31
|
-
const startSolstice = Seasons(artificialYear).dec_solstice.date;
|
|
32
|
-
const endSolstice = Seasons(artificialYear + 1).dec_solstice.date;
|
|
33
|
-
const startNewYear = Date.UTC(startSolstice.getUTCFullYear(), startSolstice.getUTCMonth(), startSolstice.getUTCDate() + (startSolstice.getUTCHours() >= 12 ? 1 : 0), 12, 0, 0);
|
|
34
|
-
const endNewYear = Date.UTC(endSolstice.getUTCFullYear(), endSolstice.getUTCMonth(), endSolstice.getUTCDate() + (endSolstice.getUTCHours() >= 12 ? 1 : 0), 12, 0, 0);
|
|
35
|
-
const context = {
|
|
36
|
-
start: parseInt(String(startNewYear + (-longitude + 180) * NaturalDate.MILLISECONDS_PER_DAY / 360)),
|
|
37
|
-
duration: (endNewYear - startNewYear) / NaturalDate.MILLISECONDS_PER_DAY
|
|
38
|
-
};
|
|
39
|
-
yearContextCache.set(cacheKey, context);
|
|
40
|
-
return context;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Natural date class for converting artificial (Gregorian) dates to natural time.
|
|
44
|
-
*
|
|
45
|
-
* The NaturalDate class provides a complete implementation of the natural time system,
|
|
46
|
-
* which is based on natural cycles:
|
|
47
|
-
* - Years begin at the winter solstice
|
|
48
|
-
* - Each year has 13 moons (months) of 28 days each, plus 1-2 "rainbow days"
|
|
49
|
-
* - Weeks are 7 days
|
|
50
|
-
* - Time is measured in 360 degrees for a full day cycle
|
|
51
|
-
*
|
|
52
|
-
* This class handles the conversion between Gregorian calendar dates and natural time,
|
|
53
|
-
* accounting for longitude adjustments to provide location-specific natural time.
|
|
54
|
-
*/
|
|
55
|
-
export class NaturalDate {
|
|
56
|
-
/**
|
|
57
|
-
* Creates a new natural date instance.
|
|
58
|
-
*
|
|
59
|
-
* Converts a Gregorian date to natural time based on the specified longitude.
|
|
60
|
-
* The longitude is used to adjust the natural time for the local position on Earth.
|
|
61
|
-
*
|
|
62
|
-
* @param date - JavaScript Date object, Unix timestamp, or date string
|
|
63
|
-
* @param longitude - Longitude in degrees (-180 to 180)
|
|
64
|
-
* @throws {Error} If inputs are invalid
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* // Create a natural date for the current time in Paris (longitude 2.3522)
|
|
68
|
-
* const parisNaturalDate = new NaturalDate(new Date(), 2.3522);
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* // Create a natural date for a specific time in Tokyo (longitude 139.6503)
|
|
72
|
-
* const tokyoNaturalDate = new NaturalDate('2023-06-21T12:00:00', 139.6503);
|
|
73
|
-
*/
|
|
74
|
-
constructor(date, longitude) {
|
|
75
|
-
// Validate longitude
|
|
76
|
-
if (longitude !== undefined && (typeof longitude !== 'number' || longitude < -180 || longitude > 180)) {
|
|
77
|
-
throw new Error('Longitude must be between -180 and +180');
|
|
78
|
-
}
|
|
79
|
-
const dateObj = new Date(date || Date.now());
|
|
80
|
-
if (isNaN(dateObj.getTime())) {
|
|
81
|
-
throw new Error('Invalid date provided');
|
|
82
|
-
}
|
|
83
|
-
this.unixTime = dateObj.getTime();
|
|
84
|
-
this.longitude = longitude || 0;
|
|
85
|
-
if (Number.isFinite(this.unixTime)) {
|
|
86
|
-
// YEAR START & DURATION
|
|
87
|
-
let yearContext = calculateYearContext(dateObj.getUTCFullYear() - 1, this.longitude);
|
|
88
|
-
// Correction if between the beginning of natural year and the end of the artificial year
|
|
89
|
-
if (this.unixTime - yearContext.start >= yearContext.duration * NaturalDate.MILLISECONDS_PER_DAY)
|
|
90
|
-
yearContext = calculateYearContext(dateObj.getUTCFullYear(), this.longitude);
|
|
91
|
-
this.yearStart = yearContext.start;
|
|
92
|
-
this.yearDuration = yearContext.duration;
|
|
93
|
-
const timeSinceLocalYearStart = (this.unixTime - this.yearStart) / NaturalDate.MILLISECONDS_PER_DAY;
|
|
94
|
-
// YEAR
|
|
95
|
-
this.year = new Date(this.yearStart).getUTCFullYear() - new Date(NaturalDate.END_OF_ARTIFICIAL_TIME).getUTCFullYear() + 1;
|
|
96
|
-
// MOON
|
|
97
|
-
this.moon = Math.floor(timeSinceLocalYearStart / 28) + 1;
|
|
98
|
-
// HEPTAD
|
|
99
|
-
this.week = Math.floor(timeSinceLocalYearStart / 7) + 1;
|
|
100
|
-
this.weekOfMoon = Math.floor(timeSinceLocalYearStart / 7) % 4 + 1;
|
|
101
|
-
// DAY
|
|
102
|
-
this.day = Math.floor((this.unixTime - (NaturalDate.END_OF_ARTIFICIAL_TIME + (-this.longitude + 180) * NaturalDate.MILLISECONDS_PER_DAY / 360)) / NaturalDate.MILLISECONDS_PER_DAY);
|
|
103
|
-
this.dayOfYear = Math.floor(timeSinceLocalYearStart) + 1;
|
|
104
|
-
this.dayOfMoon = Math.floor(timeSinceLocalYearStart) % 28 + 1;
|
|
105
|
-
this.dayOfWeek = Math.floor(timeSinceLocalYearStart) % 7 + 1;
|
|
106
|
-
// NADIR (i.e day start, midnight)
|
|
107
|
-
this.nadir = this.yearStart + Math.floor(timeSinceLocalYearStart) * NaturalDate.MILLISECONDS_PER_DAY;
|
|
108
|
-
// TIME
|
|
109
|
-
this.time = (this.unixTime - this.nadir) * 360 / NaturalDate.MILLISECONDS_PER_DAY;
|
|
110
|
-
// RAINBOW DAY
|
|
111
|
-
this.isRainbowDay = this.dayOfYear > 13 * 28;
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
throw new Error('Argument must be a Date object or a Unix timestamp');
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Gets the time of an astronomical event in natural degrees.
|
|
118
|
-
*
|
|
119
|
-
* Converts an event timestamp to natural degrees (0-360°) within the current natural day.
|
|
120
|
-
* Returns false if the event occurs outside the current natural day.
|
|
121
|
-
*
|
|
122
|
-
* This is useful for calculating the position of celestial events like sunrise, sunset,
|
|
123
|
-
* moonrise, or moonset within the natural time system.
|
|
124
|
-
*
|
|
125
|
-
* @param event - Event timestamp (Date object, Unix timestamp, or date string)
|
|
126
|
-
* @returns Event time in natural degrees (0-360°) or false if out of range
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* // Calculate sunrise time in natural degrees
|
|
130
|
-
* const naturalDate = new NaturalDate(new Date(), 0);
|
|
131
|
-
* const sunrise = '2023-01-01T06:00:00'; // Example sunrise at 6:00 AM
|
|
132
|
-
* const sunriseInDegrees = naturalDate.getTimeOfEvent(sunrise);
|
|
133
|
-
* console.log(`Sunrise occurs at ${sunriseInDegrees}°`);
|
|
134
|
-
*/
|
|
135
|
-
getTimeOfEvent(event) {
|
|
136
|
-
// Make sure it's a unix timestamp
|
|
137
|
-
const eventTime = new Date(event).getTime();
|
|
138
|
-
// Check if not out of range
|
|
139
|
-
if (eventTime < this.nadir || eventTime > this.nadir + NaturalDate.MILLISECONDS_PER_DAY)
|
|
140
|
-
return false;
|
|
141
|
-
return (eventTime - this.nadir) * (360 / NaturalDate.MILLISECONDS_PER_DAY);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Exports current date as a full ISO formatted string.
|
|
145
|
-
*
|
|
146
|
-
* The format is: "YYY)MM)DD TTT°DD NT±LLL.L"
|
|
147
|
-
* - YYY: Natural year (padded to 3 digits)
|
|
148
|
-
* - MM: Moon number (padded to 2 digits)
|
|
149
|
-
* - DD: Day of moon (padded to 2 digits)
|
|
150
|
-
* - TTT: Time in degrees (padded to 3 digits)
|
|
151
|
-
* - DD: Decimal degrees (2 digits)
|
|
152
|
-
* - ±LLL.L: Longitude with sign and 1 decimal
|
|
153
|
-
*
|
|
154
|
-
* @returns {string} Formatted natural date string
|
|
155
|
-
*/
|
|
156
|
-
toString() {
|
|
157
|
-
return `${this.toDateString()} ${this.toTimeString()} ${this.toLongitudeString()}`;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Exports the date part of the natural date.
|
|
161
|
-
*
|
|
162
|
-
* @param separator - Separator character between components (default: ')')
|
|
163
|
-
* @returns Formatted date string
|
|
164
|
-
*/
|
|
165
|
-
toDateString(separator = ')') {
|
|
166
|
-
if (this.isRainbowDay) {
|
|
167
|
-
const isSecondRainbowDay = this.dayOfYear === 366;
|
|
168
|
-
return `${this.toYearString()}${separator}RAINBOW${isSecondRainbowDay ? '+' : ''}`;
|
|
169
|
-
}
|
|
170
|
-
return `${this.toYearString()}${separator}${this.toMoonString()}${separator}${this.toDayOfMoonString()}`;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Exports the time part of the natural date.
|
|
174
|
-
*
|
|
175
|
-
* @param decimals - Number of decimal places for time (default: 2)
|
|
176
|
-
* @param rounding - Rounding increment for time (default: 1)
|
|
177
|
-
* @returns Formatted time string
|
|
178
|
-
*/
|
|
179
|
-
toTimeString(decimals = 2, rounding = 0.01) {
|
|
180
|
-
let time = this.time;
|
|
181
|
-
// Round to the nearest decimal increment
|
|
182
|
-
if (rounding > 0) {
|
|
183
|
-
time = Math.round(time / rounding) * rounding;
|
|
184
|
-
// Handle edge case where rounding pushes us to 360°
|
|
185
|
-
if (time >= 360) {
|
|
186
|
-
time = 0;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Format the integer part to 3 digits
|
|
190
|
-
const integerPart = Math.floor(time).toString().padStart(3, '0');
|
|
191
|
-
// Format the decimal part if needed
|
|
192
|
-
const decimalPart = decimals > 0
|
|
193
|
-
? (time % 1).toFixed(decimals).substring(2).padEnd(decimals, '0')
|
|
194
|
-
: '';
|
|
195
|
-
return `${integerPart}°${decimalPart}`;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Exports the longitude part of the natural date.
|
|
199
|
-
*
|
|
200
|
-
* @param decimals - Number of decimal places for longitude (default: 1)
|
|
201
|
-
* @returns Formatted longitude string
|
|
202
|
-
*/
|
|
203
|
-
toLongitudeString(decimals = 1) {
|
|
204
|
-
// Consider longitudes very close to 0 (within 0.5 degrees) as NTZ
|
|
205
|
-
if (Math.abs(this.longitude) < 0.5) {
|
|
206
|
-
return 'NTZ';
|
|
207
|
-
}
|
|
208
|
-
const prefix = 'NT';
|
|
209
|
-
const sign = this.longitude >= 0 ? '+' : '-';
|
|
210
|
-
const absLongitude = Math.abs(this.longitude);
|
|
211
|
-
const integerPart = Math.floor(absLongitude).toString().padStart(1, '0');
|
|
212
|
-
const decimalPart = decimals > 0
|
|
213
|
-
? (absLongitude % 1).toFixed(decimals).substring(2)
|
|
214
|
-
: '';
|
|
215
|
-
return `${prefix}${sign}${integerPart}${decimals > 0 ? '.' + decimalPart : ''}`;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Exports the year part of the natural date.
|
|
219
|
-
*
|
|
220
|
-
* @returns Formatted year string
|
|
221
|
-
*/
|
|
222
|
-
toYearString() {
|
|
223
|
-
const absYear = Math.abs(this.year);
|
|
224
|
-
const sign = this.year < 0 ? '-' : '';
|
|
225
|
-
return `${sign}${absYear.toString().padStart(3, '0')}`;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Exports the moon part of the natural date.
|
|
229
|
-
*
|
|
230
|
-
* @returns Formatted moon string
|
|
231
|
-
*/
|
|
232
|
-
toMoonString() {
|
|
233
|
-
return this.moon.toString().padStart(2, '0');
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Exports the day of moon part of the natural date.
|
|
237
|
-
*
|
|
238
|
-
* @returns Formatted day of moon string
|
|
239
|
-
*/
|
|
240
|
-
toDayOfMoonString() {
|
|
241
|
-
return this.dayOfMoon.toString().padStart(2, '0');
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Number of milliseconds in a day
|
|
246
|
-
*/
|
|
247
|
-
NaturalDate.MILLISECONDS_PER_DAY = 86400000; // 24 * 60 * 60 * 1000
|
|
248
|
-
/**
|
|
249
|
-
* End date of the artificial time era (December 21, 2012 12:00 UTC)
|
|
250
|
-
* This is the reference point for natural time calculations
|
|
251
|
-
*/
|
|
252
|
-
NaturalDate.END_OF_ARTIFICIAL_TIME = Date.UTC(2012, 11, 21, 12, 0, 0);
|
|
253
|
-
/**
|
|
254
|
-
* Clears the internal year context cache.
|
|
255
|
-
* Exposed for testing or advanced usage without exposing the cache itself.
|
|
256
|
-
*/
|
|
257
|
-
export function resetYearContextCache() {
|
|
258
|
-
yearContextCache.clear();
|
|
259
|
-
}
|
|
260
|
-
//# sourceMappingURL=NaturalDate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NaturalDate.js","sourceRoot":"","sources":["../../src/core/NaturalDate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAU3C;;;GAGG;AACH,MAAM,gBAAgB,GAA6B,IAAI,GAAG,EAAE,CAAC;AAE7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,oBAAoB,GAAG,CAAC,cAAsB,EAAE,SAAiB,EAAe,EAAE;IACpF,MAAM,QAAQ,GAAG,GAAG,cAAc,IAAI,SAAS,EAAE,CAAC;IAElD,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;IAC3C,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;IAChE,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;IAElE,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CACzB,aAAa,CAAC,cAAc,EAAE,EAC9B,aAAa,CAAC,WAAW,EAAE,E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appings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,oCAAoC;AACpC,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE3E;;GAEG;AACH,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,OAAO,EACP,MAAM,EACT,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,WAAW;IACvB,6DAA6D;IAC7D,qBAAqB,EAAE,CAAC;IACxB,mBAAmB,EAAE,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,OAAO,EACH,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,uFAAuF;AACvF,mFAAmF;AACnF,uFAAuF;AACvF,mFAAmF"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for natural-time-js
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Interface for NaturalDate class to avoid circular dependencies
|
|
6
|
-
*/
|
|
7
|
-
export interface INaturalDate {
|
|
8
|
-
/** Artificial gregorian date (UNIX timestamp) */
|
|
9
|
-
unixTime: number;
|
|
10
|
-
/** Longitude in degrees (-180 to 180) */
|
|
11
|
-
longitude: number;
|
|
12
|
-
/** Current year (year 1: 2012/2013) */
|
|
13
|
-
year: number;
|
|
14
|
-
/** Current moon (between 1 and 14) */
|
|
15
|
-
moon: number;
|
|
16
|
-
/** Current week (between 1 and 53) */
|
|
17
|
-
week: number;
|
|
18
|
-
/** Current week of the moon (between 1 and 4) */
|
|
19
|
-
weekOfMoon: number;
|
|
20
|
-
/** Number of days passed since END_OF_ARTIFICIAL_TIME */
|
|
21
|
-
day: number;
|
|
22
|
-
/** Current day of the year (between 1 and 366) */
|
|
23
|
-
dayOfYear: number;
|
|
24
|
-
/** Current day of the moon (between 1 and 28) */
|
|
25
|
-
dayOfMoon: number;
|
|
26
|
-
/** Current day of the week (between 1 and 7) */
|
|
27
|
-
dayOfWeek: number;
|
|
28
|
-
/** True if current day is rainbow day */
|
|
29
|
-
isRainbowDay: boolean;
|
|
30
|
-
/** Current time (between 0 and 359.999...) */
|
|
31
|
-
time: number;
|
|
32
|
-
/** Beginning of the year at the current longitude (UNIX timestamp) */
|
|
33
|
-
yearStart: number;
|
|
34
|
-
/** Numbers of days in the current year (between 365 and 366) */
|
|
35
|
-
yearDuration: number;
|
|
36
|
-
/** Beginning of the day at the current longitude (UNIX timestamp) */
|
|
37
|
-
nadir: number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Year context for natural date calculations
|
|
41
|
-
*/
|
|
42
|
-
export interface YearContext {
|
|
43
|
-
/** Start timestamp of the year */
|
|
44
|
-
start: number;
|
|
45
|
-
/** Duration of the year in days */
|
|
46
|
-
duration: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Sun altitude information
|
|
50
|
-
*/
|
|
51
|
-
export interface SunAltitude {
|
|
52
|
-
/** Current altitude of the sun in degrees */
|
|
53
|
-
altitude: number;
|
|
54
|
-
/** Highest altitude the sun will reach on this day */
|
|
55
|
-
highestAltitude: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Sun events throughout the day
|
|
59
|
-
*/
|
|
60
|
-
export interface SunEvents {
|
|
61
|
-
/** Time of sunrise in degrees (0-360) or false if no sunrise */
|
|
62
|
-
sunrise: number | false;
|
|
63
|
-
/** Time of sunset in degrees (0-360) or false if no sunset */
|
|
64
|
-
sunset: number | false;
|
|
65
|
-
/** Time when night starts in degrees (0-360) or false if no night start */
|
|
66
|
-
nightStart: number | false;
|
|
67
|
-
/** Time when night ends in degrees (0-360) or false if no night end */
|
|
68
|
-
nightEnd: number | false;
|
|
69
|
-
/** Time when morning golden hour starts in degrees (0-360) or false if no morning golden hour */
|
|
70
|
-
morningGoldenHour: number | false;
|
|
71
|
-
/** Time when evening golden hour starts in degrees (0-360) or false if no evening golden hour */
|
|
72
|
-
eveningGoldenHour: number | false;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Moon position information
|
|
76
|
-
*/
|
|
77
|
-
export interface MoonPosition {
|
|
78
|
-
/** Moon phase in degrees (0-360) */
|
|
79
|
-
phase: number;
|
|
80
|
-
/** Current altitude of the moon in degrees */
|
|
81
|
-
altitude: number;
|
|
82
|
-
/** Highest altitude the moon will reach on this day */
|
|
83
|
-
highestAltitude: number;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Moon events throughout the day
|
|
87
|
-
*/
|
|
88
|
-
export interface MoonEvents {
|
|
89
|
-
/** Time of moonrise in degrees (0-360) or false if no moonrise */
|
|
90
|
-
moonrise: number | false;
|
|
91
|
-
/** Time of moonset in degrees (0-360) or false if no moonset */
|
|
92
|
-
moonset: number | false;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Hemisphere identifiers
|
|
96
|
-
*/
|
|
97
|
-
export declare enum Hemisphere {
|
|
98
|
-
NORTH = "NORTH",
|
|
99
|
-
SOUTH = "SOUTH"
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Season day markers
|
|
103
|
-
*/
|
|
104
|
-
export interface Seasons {
|
|
105
|
-
/** Day 91 (typically April 1st) */
|
|
106
|
-
SUMMER_START_DAY: number;
|
|
107
|
-
/** Day 273 (typically September 30th) */
|
|
108
|
-
SUMMER_END_DAY: number;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Solar altitude thresholds
|
|
112
|
-
*/
|
|
113
|
-
export interface Angles {
|
|
114
|
-
/** Night altitude threshold in degrees */
|
|
115
|
-
NIGHT_ALTITUDE: number;
|
|
116
|
-
/** Golden hour altitude threshold in degrees */
|
|
117
|
-
GOLDEN_HOUR_ALTITUDE: number;
|
|
118
|
-
}
|
package/dist/types/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for natural-time-js
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Hemisphere identifiers
|
|
6
|
-
*/
|
|
7
|
-
export var Hemisphere;
|
|
8
|
-
(function (Hemisphere) {
|
|
9
|
-
Hemisphere["NORTH"] = "NORTH";
|
|
10
|
-
Hemisphere["SOUTH"] = "SOUTH";
|
|
11
|
-
})(Hemisphere || (Hemisphere = {}));
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkGH;;GAEG;AACH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,6BAAe,CAAA;AACjB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module natural-time-js/validators
|
|
3
|
-
* @description Validation utilities for natural time calculations.
|
|
4
|
-
* This module provides functions to validate inputs for natural time operations,
|
|
5
|
-
* ensuring that values are within acceptable ranges and of the correct types.
|
|
6
|
-
*/
|
|
7
|
-
import { NaturalDate } from '../core/NaturalDate.js';
|
|
8
|
-
/**
|
|
9
|
-
* Validates if a value is a finite number.
|
|
10
|
-
*
|
|
11
|
-
* This is a utility function that checks if a value is a valid number
|
|
12
|
-
* (not NaN, not Infinity, and actually a number type).
|
|
13
|
-
*
|
|
14
|
-
* @param value - Value to validate
|
|
15
|
-
* @returns True if value is a valid number
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* isValidNumber(42); // true
|
|
19
|
-
* isValidNumber('42'); // false (string, not number)
|
|
20
|
-
* isValidNumber(NaN); // false
|
|
21
|
-
* isValidNumber(Infinity); // false
|
|
22
|
-
*/
|
|
23
|
-
export declare const isValidNumber: (value: unknown) => value is number;
|
|
24
|
-
/**
|
|
25
|
-
* Validates if a latitude value is within the valid range.
|
|
26
|
-
*
|
|
27
|
-
* Latitude must be a number between -90° (South Pole) and 90° (North Pole).
|
|
28
|
-
*
|
|
29
|
-
* @param latitude - Latitude in degrees to validate
|
|
30
|
-
* @returns True if latitude is valid
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* isValidLatitude(45.5); // true
|
|
34
|
-
* isValidLatitude(-90); // true (South Pole)
|
|
35
|
-
* isValidLatitude(90); // true (North Pole)
|
|
36
|
-
* isValidLatitude(91); // false (out of range)
|
|
37
|
-
*/
|
|
38
|
-
export declare const isValidLatitude: (latitude: unknown) => latitude is number;
|
|
39
|
-
/**
|
|
40
|
-
* Validates if a longitude value is within the valid range.
|
|
41
|
-
*
|
|
42
|
-
* Longitude must be a number between -180° and 180°, where:
|
|
43
|
-
* - 0° is the Prime Meridian (Greenwich)
|
|
44
|
-
* - Positive values are East longitude
|
|
45
|
-
* - Negative values are West longitude
|
|
46
|
-
*
|
|
47
|
-
* @param longitude - Longitude in degrees to validate
|
|
48
|
-
* @returns True if longitude is valid
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* isValidLongitude(0); // true (Prime Meridian)
|
|
52
|
-
* isValidLongitude(180); // true (International Date Line)
|
|
53
|
-
* isValidLongitude(-180); // true (International Date Line)
|
|
54
|
-
* isValidLongitude(181); // false (out of range)
|
|
55
|
-
*/
|
|
56
|
-
export declare const isValidLongitude: (longitude: unknown) => longitude is number;
|
|
57
|
-
/**
|
|
58
|
-
* Validates if an angle value is within the valid range.
|
|
59
|
-
*
|
|
60
|
-
* Angles in natural time are measured in degrees from 0° to 360°,
|
|
61
|
-
* representing a full circle. This is used for time of day and
|
|
62
|
-
* celestial positions.
|
|
63
|
-
*
|
|
64
|
-
* @param angle - Angle in degrees to validate
|
|
65
|
-
* @returns True if angle is valid
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* isValidAngle(180); // true (half circle)
|
|
69
|
-
* isValidAngle(360); // true (full circle)
|
|
70
|
-
* isValidAngle(0); // true (beginning of circle)
|
|
71
|
-
* isValidAngle(361); // false (out of range)
|
|
72
|
-
* isValidAngle(-1); // false (out of range)
|
|
73
|
-
*/
|
|
74
|
-
export declare const isValidAngle: (angle: unknown) => angle is number;
|
|
75
|
-
/**
|
|
76
|
-
* Validates if a timestamp is a valid Unix time.
|
|
77
|
-
*
|
|
78
|
-
* Unix timestamps represent the number of milliseconds since
|
|
79
|
-
* January 1, 1970, 00:00:00 UTC (the Unix epoch).
|
|
80
|
-
* Valid timestamps must be positive numbers.
|
|
81
|
-
*
|
|
82
|
-
* @param timestamp - Unix timestamp in milliseconds
|
|
83
|
-
* @returns True if timestamp is valid
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* isValidTimestamp(Date.now()); // true
|
|
87
|
-
* isValidTimestamp(0); // false (Unix epoch exactly)
|
|
88
|
-
* isValidTimestamp(-1); // false (before Unix epoch)
|
|
89
|
-
*/
|
|
90
|
-
export declare const isValidTimestamp: (timestamp: unknown) => timestamp is number;
|
|
91
|
-
/**
|
|
92
|
-
* Validates if an object is a properly initialized NaturalDate instance.
|
|
93
|
-
*
|
|
94
|
-
* This function performs a comprehensive check of a NaturalDate object,
|
|
95
|
-
* verifying that all properties are present and within valid ranges.
|
|
96
|
-
* It's used to ensure that only valid NaturalDate objects are used in calculations.
|
|
97
|
-
*
|
|
98
|
-
* @param date - Value to validate
|
|
99
|
-
* @returns True if value is a valid NaturalDate instance
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* const naturalDate = new NaturalDate(new Date(), 0);
|
|
103
|
-
* isValidNaturalDate(naturalDate); // true
|
|
104
|
-
*
|
|
105
|
-
* isValidNaturalDate({}); // false (not a NaturalDate instance)
|
|
106
|
-
* isValidNaturalDate(null); // false
|
|
107
|
-
*/
|
|
108
|
-
export declare const isValidNaturalDate: (date: unknown) => date is NaturalDate;
|
|
109
|
-
/**
|
|
110
|
-
* Validates if a string is a valid cache key.
|
|
111
|
-
*
|
|
112
|
-
* Cache keys are used for storing and retrieving calculated values
|
|
113
|
-
* to improve performance. Valid keys must be non-empty strings.
|
|
114
|
-
*
|
|
115
|
-
* @param key - Cache key to validate
|
|
116
|
-
* @returns True if key is valid
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* isValidCacheKey('SUN_2023_45.5_0'); // true
|
|
120
|
-
* isValidCacheKey(''); // false (empty string)
|
|
121
|
-
* isValidCacheKey(123); // false (not a string)
|
|
122
|
-
*/
|
|
123
|
-
export declare const isValidCacheKey: (key: unknown) => key is string;
|
|
124
|
-
/**
|
|
125
|
-
* Throws a formatted error for invalid parameters.
|
|
126
|
-
*
|
|
127
|
-
* This utility function creates consistent error messages for validation failures,
|
|
128
|
-
* making it easier to identify and fix issues with invalid inputs.
|
|
129
|
-
*
|
|
130
|
-
* @param paramName - Name of the invalid parameter
|
|
131
|
-
* @param value - Invalid value
|
|
132
|
-
* @param expectedType - Description of expected type/format
|
|
133
|
-
* @throws {Error} Formatted validation error
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* // If latitude is invalid:
|
|
137
|
-
* throwValidationError('latitude', 95, 'number between -90 and 90');
|
|
138
|
-
* // Throws: "Error: Invalid latitude: 95. Expected number between -90 and 90"
|
|
139
|
-
*/
|
|
140
|
-
export declare const throwValidationError: (paramName: string, value: unknown, expectedType: string) => never;
|