natural-time-js 2.1.0 → 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.
@@ -1,108 +0,0 @@
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.js';
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
- }
65
- /**
66
- * Interface for moon events
67
- */
68
- interface MoonEvents {
69
- moonrise: number;
70
- moonset: number;
71
- highestAltitude: number;
72
- }
73
- /**
74
- * Interface for mustaches range information
75
- */
76
- interface MustachesRange {
77
- winterSunrise: number;
78
- winterSunset: number;
79
- summerSunrise: number;
80
- summerSunset: number;
81
- averageMustacheAngle: number;
82
- }
83
- /**
84
- * Clears the internal astronomy cache.
85
- * Exposed for testing or advanced usage without exposing the cache itself.
86
- */
87
- export declare function resetAstronomyCache(): void;
88
- /**
89
- * Calculates the sun's altitude at a specific natural time and location.
90
- */
91
- export declare function NaturalSunAltitude(naturalDate: NaturalDate, latitude: number): SunAltitude;
92
- /**
93
- * Calculates sun events for a specific natural date and location.
94
- */
95
- export declare function NaturalSunEvents(naturalDate: NaturalDate, latitude: number): SunEvents;
96
- /**
97
- * Calculates the moon's position and phase.
98
- */
99
- export declare function NaturalMoonPosition(naturalDate: NaturalDate, latitude: number): MoonPosition;
100
- /**
101
- * Calculates moon events for a specific natural date and location.
102
- */
103
- export declare function NaturalMoonEvents(naturalDate: NaturalDate, latitude: number): MoonEvents;
104
- /**
105
- * Calculates the range of sun positions between winter and summer solstices (average mustaches angle)
106
- */
107
- export declare function MustachesRange(naturalDate: NaturalDate, latitude: number): MustachesRange;
108
- export {};
@@ -1,244 +0,0 @@
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.js';
13
- import { Body, Observer, SearchHourAngle, SearchRiseSet, SearchAltitude, MoonPhase, Equator, Horizon, Seasons } from 'astronomy-engine';
14
- import { isValidLatitude, isValidNaturalDate, throwValidationError } from '../utils/validators.js';
15
- /**
16
- * Hemisphere identifiers for geographical calculations.
17
- */
18
- export var HEMISPHERES;
19
- (function (HEMISPHERES) {
20
- /** Northern hemisphere (latitude >= 0) */
21
- HEMISPHERES["NORTH"] = "NORTH";
22
- /** Southern hemisphere (latitude < 0) */
23
- HEMISPHERES["SOUTH"] = "SOUTH";
24
- })(HEMISPHERES || (HEMISPHERES = {}));
25
- /**
26
- * Day numbers marking the start and end of summer season.
27
- */
28
- export const SEASONS = {
29
- /** Day 91 (typically April 1st) - Start of summer in Northern hemisphere */
30
- SUMMER_START_DAY: 91,
31
- /** Day 273 (typically September 30th) - End of summer in Northern hemisphere */
32
- SUMMER_END_DAY: 273
33
- };
34
- /**
35
- * Solar altitude thresholds in degrees for different daylight conditions.
36
- */
37
- export const ANGLES = {
38
- /** Altitude below which astronomical night begins (-12°) */
39
- NIGHT_ALTITUDE: -12,
40
- /** Altitude below which golden hour lighting occurs (6°) */
41
- GOLDEN_HOUR_ALTITUDE: 6
42
- };
43
- /**
44
- * Cache for astronomical calculations to improve performance.
45
- */
46
- const astroCache = new Map();
47
- /**
48
- * Clears the internal astronomy cache.
49
- * Exposed for testing or advanced usage without exposing the cache itself.
50
- */
51
- export function resetAstronomyCache() {
52
- astroCache.clear();
53
- }
54
- /**
55
- * Determines the hemisphere based on latitude.
56
- */
57
- const getHemisphere = (latitude) => latitude >= 0 ? HEMISPHERES.NORTH : HEMISPHERES.SOUTH;
58
- /**
59
- * Determines if the current day is in the summer season based on hemisphere.
60
- */
61
- const isSummerSeason = (dayOfYear, latitude) => {
62
- const hemisphere = getHemisphere(latitude);
63
- return hemisphere === HEMISPHERES.NORTH
64
- ? (dayOfYear >= SEASONS.SUMMER_START_DAY && dayOfYear <= SEASONS.SUMMER_END_DAY)
65
- : (dayOfYear <= SEASONS.SUMMER_START_DAY || dayOfYear >= SEASONS.SUMMER_END_DAY);
66
- };
67
- /**
68
- * Creates an observer object for astronomical calculations.
69
- */
70
- const createObserver = (latitude, longitude) => new Observer(latitude, longitude, 0);
71
- /**
72
- * Calculates the sun's altitude at a specific natural time and location.
73
- */
74
- export function NaturalSunAltitude(naturalDate, latitude) {
75
- // Validate inputs
76
- if (!isValidNaturalDate(naturalDate)) {
77
- throwValidationError('naturalDate', naturalDate, 'NaturalDate instance');
78
- }
79
- if (!isValidLatitude(latitude)) {
80
- throwValidationError('latitude', latitude, 'number between -90 and 90');
81
- }
82
- try {
83
- const observer = createObserver(latitude, naturalDate.longitude);
84
- const date = new Date(naturalDate.unixTime);
85
- const sun = Equator(Body.Sun, date, observer, true, false);
86
- return {
87
- altitude: Math.max(Horizon(date, observer, sun.ra, sun.dec).altitude, 0),
88
- highestAltitude: SearchHourAngle(Body.Sun, observer, 0, new Date(naturalDate.nadir)).hor.altitude
89
- };
90
- }
91
- catch (error) {
92
- throw error;
93
- }
94
- }
95
- /**
96
- * Calculates sun events for a specific natural date and location.
97
- */
98
- export function NaturalSunEvents(naturalDate, latitude) {
99
- // Validate inputs
100
- if (!isValidNaturalDate(naturalDate)) {
101
- throwValidationError('naturalDate', naturalDate, 'NaturalDate instance');
102
- }
103
- if (!isValidLatitude(latitude)) {
104
- throwValidationError('latitude', latitude, 'number between -90 and 90');
105
- }
106
- const cacheKey = `SUN_${naturalDate.toDateString()}_${latitude}_${naturalDate.longitude}`;
107
- try {
108
- const cachedResult = astroCache.get(cacheKey);
109
- if (cachedResult && 'sunrise' in cachedResult) {
110
- return cachedResult;
111
- }
112
- const observer = createObserver(latitude, naturalDate.longitude);
113
- const nadir = new Date(naturalDate.nadir);
114
- const isSummer = isSummerSeason(naturalDate.dayOfYear, latitude);
115
- // Helper function to handle edge cases
116
- const getEventTime = (searchResult, isSummerDefault) => {
117
- if (!searchResult) {
118
- return isSummer ? (isSummerDefault ? 360 : 0) : 180;
119
- }
120
- return naturalDate.getTimeOfEvent(searchResult.date) || 0;
121
- };
122
- const events = {
123
- sunrise: getEventTime(SearchRiseSet(Body.Sun, observer, +1, nadir, 1), false),
124
- sunset: getEventTime(SearchRiseSet(Body.Sun, observer, -1, nadir, 1), true),
125
- nightStart: getEventTime(SearchAltitude(Body.Sun, observer, -1, nadir, 2, ANGLES.NIGHT_ALTITUDE), true),
126
- nightEnd: getEventTime(SearchAltitude(Body.Sun, observer, +1, nadir, 2, ANGLES.NIGHT_ALTITUDE), false),
127
- morningGoldenHour: getEventTime(SearchAltitude(Body.Sun, observer, +1, nadir, 2, ANGLES.GOLDEN_HOUR_ALTITUDE), false),
128
- eveningGoldenHour: getEventTime(SearchAltitude(Body.Sun, observer, -1, nadir, 2, ANGLES.GOLDEN_HOUR_ALTITUDE), true)
129
- };
130
- astroCache.set(cacheKey, events);
131
- return events;
132
- }
133
- catch (error) {
134
- throw error;
135
- }
136
- }
137
- /**
138
- * Calculates the moon's position and phase.
139
- */
140
- export function NaturalMoonPosition(naturalDate, latitude) {
141
- // Validate inputs
142
- if (!isValidNaturalDate(naturalDate)) {
143
- throwValidationError('naturalDate', naturalDate, 'NaturalDate instance');
144
- }
145
- if (!isValidLatitude(latitude)) {
146
- throwValidationError('latitude', latitude, 'number between -90 and 90');
147
- }
148
- try {
149
- const observer = createObserver(latitude, naturalDate.longitude);
150
- const date = new Date(naturalDate.unixTime);
151
- const moon = Equator(Body.Moon, date, observer, true, false);
152
- return {
153
- altitude: Math.max(Horizon(date, observer, moon.ra, moon.dec).altitude, 0),
154
- phase: MoonPhase(date),
155
- };
156
- }
157
- catch (error) {
158
- throw error;
159
- }
160
- }
161
- /**
162
- * Calculates moon events for a specific natural date and location.
163
- */
164
- export function NaturalMoonEvents(naturalDate, latitude) {
165
- // Validate inputs
166
- if (!isValidNaturalDate(naturalDate)) {
167
- throwValidationError('naturalDate', naturalDate, 'NaturalDate instance');
168
- }
169
- if (!isValidLatitude(latitude)) {
170
- throwValidationError('latitude', latitude, 'number between -90 and 90');
171
- }
172
- const cacheKey = `MOON_${naturalDate.toDateString()}_${latitude}_${naturalDate.longitude}`;
173
- try {
174
- const cachedResult = astroCache.get(cacheKey);
175
- if (cachedResult && 'moonrise' in cachedResult) {
176
- return cachedResult;
177
- }
178
- const observer = createObserver(latitude, naturalDate.longitude);
179
- const nadir = new Date(naturalDate.nadir);
180
- // Helper function to handle edge cases
181
- const getEventTime = (searchResult) => {
182
- if (!searchResult)
183
- return 0;
184
- return naturalDate.getTimeOfEvent(searchResult.date) || 0;
185
- };
186
- const events = {
187
- moonrise: getEventTime(SearchRiseSet(Body.Moon, observer, +1, nadir, 1)),
188
- moonset: getEventTime(SearchRiseSet(Body.Moon, observer, -1, nadir, 1)),
189
- highestAltitude: SearchHourAngle(Body.Moon, observer, 0, nadir).hor.altitude
190
- };
191
- astroCache.set(cacheKey, events);
192
- return events;
193
- }
194
- catch (error) {
195
- throw error;
196
- }
197
- }
198
- /**
199
- * Calculates the range of sun positions between winter and summer solstices (average mustaches angle)
200
- */
201
- export function MustachesRange(naturalDate, latitude) {
202
- // Validate inputs
203
- if (!isValidNaturalDate(naturalDate)) {
204
- throwValidationError('naturalDate', naturalDate, 'NaturalDate instance');
205
- }
206
- if (!isValidLatitude(latitude)) {
207
- throwValidationError('latitude', latitude, 'number between -90 and 90');
208
- }
209
- const currentYear = new Date(naturalDate.unixTime).getFullYear();
210
- const cacheKey = `MUSTACHES_${currentYear}_${latitude}`;
211
- try {
212
- const cachedResult = astroCache.get(cacheKey);
213
- if (cachedResult && 'winterSunrise' in cachedResult) {
214
- return cachedResult;
215
- }
216
- const currentSeasons = Seasons(currentYear);
217
- const winterSolsticeSunEvents = NaturalSunEvents(new NaturalDate(currentSeasons.dec_solstice.date, 0), latitude);
218
- const summerSolsticeSunEvents = NaturalSunEvents(new NaturalDate(currentSeasons.jun_solstice.date, 0), latitude);
219
- const averageMustacheAngle = Math.min(Math.max(latitude >= 0
220
- ? (winterSolsticeSunEvents.sunrise - summerSolsticeSunEvents.sunrise +
221
- summerSolsticeSunEvents.sunset - winterSolsticeSunEvents.sunset) / 4
222
- : (summerSolsticeSunEvents.sunrise - winterSolsticeSunEvents.sunrise +
223
- winterSolsticeSunEvents.sunset - summerSolsticeSunEvents.sunset) / 4, 0), 90);
224
- const result = {
225
- winterSunrise: winterSolsticeSunEvents.sunrise,
226
- winterSunset: winterSolsticeSunEvents.sunset,
227
- summerSunrise: summerSolsticeSunEvents.sunrise,
228
- summerSunset: summerSolsticeSunEvents.sunset,
229
- averageMustacheAngle
230
- };
231
- astroCache.set(cacheKey, result);
232
- return result;
233
- }
234
- catch (error) {
235
- return {
236
- winterSunrise: 0,
237
- winterSunset: 0,
238
- summerSunrise: 0,
239
- summerSunset: 0,
240
- averageMustacheAngle: 0
241
- };
242
- }
243
- }
244
- //# sourceMappingURL=celestial.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"celestial.js","sourceRoot":"","sources":["../../src/astronomy/celestial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACxI,OAAO,EACH,eAAe,EAEf,kBAAkB,EAClB,oBAAoB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACnB,0CAA0C;IAC1C,8BAAe,CAAA;IACf,yCAAyC;IACzC,8BAAe,CAAA;AACnB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,4EAA4E;IAC5E,gBAAgB,EAAE,EAAE;IACpB,gFAAgF;IAChF,cAAc,EAAE,GAAG;CACb,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,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CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,CAAC;YACf,oBAAoB,EAAE,CAAC;SAC1B,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -1,176 +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
- /**
6
- * Natural date class for converting artificial (Gregorian) dates to natural time.
7
- *
8
- * The NaturalDate class provides a complete implementation of the natural time system,
9
- * which is based on natural cycles:
10
- * - Years begin at the winter solstice
11
- * - Each year has 13 moons (months) of 28 days each, plus 1-2 "rainbow days"
12
- * - Weeks are 7 days
13
- * - Time is measured in 360 degrees for a full day cycle
14
- *
15
- * This class handles the conversion between Gregorian calendar dates and natural time,
16
- * accounting for longitude adjustments to provide location-specific natural time.
17
- */
18
- export declare class NaturalDate {
19
- /**
20
- * Number of milliseconds in a day
21
- */
22
- static readonly MILLISECONDS_PER_DAY: number;
23
- /**
24
- * End date of the artificial time era (December 21, 2012 12:00 UTC)
25
- * This is the reference point for natural time calculations
26
- */
27
- static readonly END_OF_ARTIFICIAL_TIME: number;
28
- /** Artificial gregorian date (UNIX timestamp) */
29
- readonly unixTime: number;
30
- /** Longitude in degrees (-180° to +180°) as provided */
31
- readonly longitude: number;
32
- /**
33
- * Number of decimal places used for longitude in calculations (default: 0).
34
- * - 0 → integer zones, 360 discrete NT zones (e.g. 1.57° → 1°)
35
- * - 1 → 0.1° precision, 3600 zones (e.g. 1.57° → 1.5°)
36
- * - n → 10^n zones globally
37
- * - Infinity → exact solar longitude, fully analog
38
- */
39
- readonly precision: number;
40
- /**
41
- * The longitude value actually used in calculations, truncated to `precision`
42
- * decimal places. Equals longitude when precision is Infinity.
43
- */
44
- readonly effectiveLongitude: number;
45
- /** Current natural year (year 001: winter solstice 2012 > winter solstice 2013) */
46
- readonly year: number;
47
- /** Current moon (month) in the natural year (1-14) */
48
- readonly moon: number;
49
- /** Current week of the natural year (1-53) */
50
- readonly week: number;
51
- /** Current week within the current moon (1-4) */
52
- readonly weekOfMoon: number;
53
- /** Number of days passed since END_OF_ARTIFICIAL_TIME */
54
- readonly day: number;
55
- /** Current day of the natural year (1-366) */
56
- readonly dayOfYear: number;
57
- /** Current day of the moon (1-28) */
58
- readonly dayOfMoon: number;
59
- /** Current day of the week (1-7) */
60
- readonly dayOfWeek: number;
61
- /** True if current day is a rainbow day (day beyond the 13 moons) */
62
- readonly isRainbowDay: boolean;
63
- /** Current time in natural degrees (0-360°) */
64
- readonly time: number;
65
- /** Beginning of the natural year at the current longitude (UNIX timestamp) */
66
- readonly yearStart: number;
67
- /** Number of days in the current natural year (365 or 366) */
68
- readonly yearDuration: number;
69
- /** Beginning of the current natural day at the current longitude (UNIX timestamp) */
70
- readonly nadir: number;
71
- /**
72
- * Creates a new natural date instance.
73
- *
74
- * Converts a Gregorian date to natural time based on the specified longitude.
75
- * The longitude is used to adjust the natural time for the local position on Earth.
76
- *
77
- * @param date - JavaScript Date object, Unix timestamp, or date string
78
- * @param longitude - Longitude in degrees (-180 to 180)
79
- * @param precision - Number of decimal places used for longitude in calculations (default: 0).
80
- * - 0 → integer zones, 360 discrete NT zones (e.g. 2.3522° → 2°)
81
- * - 1 → 0.1° precision, 3600 zones (e.g. 2.3522° → 2.3°)
82
- * - Infinity → exact solar longitude, fully analog
83
- * @throws {Error} If inputs are invalid
84
- *
85
- * @example
86
- * // Default (precision=0) — Paris 2.3522° → calculated as if at 2°
87
- * const parisNaturalDate = new NaturalDate(new Date(), 2.3522);
88
- *
89
- * @example
90
- * // Analog mode — uses exact longitude
91
- * const parisAnalog = new NaturalDate(new Date(), 2.3522, Infinity);
92
- */
93
- constructor(date: Date | number | string | null | undefined, longitude?: number, precision?: number);
94
- /**
95
- * Gets the time of an astronomical event in natural degrees.
96
- *
97
- * Converts an event timestamp to natural degrees (0-360°) within the current natural day.
98
- * Returns false if the event occurs outside the current natural day.
99
- *
100
- * This is useful for calculating the position of celestial events like sunrise, sunset,
101
- * moonrise, or moonset within the natural time system.
102
- *
103
- * @param event - Event timestamp (Date object, Unix timestamp, or date string)
104
- * @returns Event time in natural degrees (0-360°) or false if out of range
105
- *
106
- * @example
107
- * // Calculate sunrise time in natural degrees
108
- * const naturalDate = new NaturalDate(new Date(), 0);
109
- * const sunrise = '2023-01-01T06:00:00'; // Example sunrise at 6:00 AM
110
- * const sunriseInDegrees = naturalDate.getTimeOfEvent(sunrise);
111
- * console.log(`Sunrise occurs at ${sunriseInDegrees}°`);
112
- */
113
- getTimeOfEvent(event: Date | number | string): number | false;
114
- /**
115
- * Exports current date as a full ISO formatted string.
116
- *
117
- * The format is: "YYY)MM)DD TTT°DD NT±LLL.L"
118
- * - YYY: Natural year (padded to 3 digits)
119
- * - MM: Moon number (padded to 2 digits)
120
- * - DD: Day of moon (padded to 2 digits)
121
- * - TTT: Time in degrees (padded to 3 digits)
122
- * - DD: Decimal degrees (2 digits)
123
- * - ±LLL.L: Longitude with sign and 1 decimal
124
- *
125
- * @returns {string} Formatted natural date string
126
- */
127
- toString(): string;
128
- /**
129
- * Exports the date part of the natural date.
130
- *
131
- * @param separator - Separator character between components (default: ')')
132
- * @returns Formatted date string
133
- */
134
- toDateString(separator?: string): string;
135
- /**
136
- * Exports the time part of the natural date.
137
- *
138
- * @param decimals - Number of decimal places for time (default: 2)
139
- * @param rounding - Rounding increment for time (default: 1)
140
- * @returns Formatted time string
141
- */
142
- toTimeString(decimals?: number, rounding?: number): string;
143
- /**
144
- * Exports the longitude part of the natural date.
145
- *
146
- * @param decimals - Number of decimal places for longitude.
147
- * Defaults to `this.precision` so the displayed zone matches the one used in calculations
148
- * (e.g. precision=0 → "NT+2", precision=1 → "NT+2.3").
149
- * When precision is Infinity, defaults to 0 (integer zone label).
150
- * @returns Formatted longitude string
151
- */
152
- toLongitudeString(decimals?: number): string;
153
- /**
154
- * Exports the year part of the natural date.
155
- *
156
- * @returns Formatted year string
157
- */
158
- toYearString(): string;
159
- /**
160
- * Exports the moon part of the natural date.
161
- *
162
- * @returns Formatted moon string
163
- */
164
- toMoonString(): string;
165
- /**
166
- * Exports the day of moon part of the natural date.
167
- *
168
- * @returns Formatted day of moon string
169
- */
170
- toDayOfMoonString(): string;
171
- }
172
- /**
173
- * Clears the internal year context cache.
174
- * Exposed for testing or advanced usage without exposing the cache itself.
175
- */
176
- export declare function resetYearContextCache(): void;