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/package.json CHANGED
@@ -1,20 +1,14 @@
1
1
  {
2
2
  "name": "natural-time-js",
3
- "version": "2.0.6",
4
- "description": "Natural time is a fresh, elegant, and coherent way of measuring the movements of time here on the Earth. This new time standard is based on common sense and the observation of natural cycles. Learn more: https://naturaltime.app. This JavaScript Class translates gregorian artificial datetime to natural datetime",
3
+ "version": "3.0.0",
4
+ "description": "Natural Time, the reference implementation: the day in 360 degrees of sun at your longitude, the year in 13 moons of 28 days from the winter solstice. https://naturaltime.app",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "build": "tsc",
10
- "build:watch": "tsc --watch",
11
10
  "test": "jest",
12
- "test:watch": "jest --watch",
13
- "test:coverage": "jest --coverage",
14
- "docs": "jsdoc -c jsdoc.json",
15
- "docs:dev": "jsdoc -c jsdoc.json -w",
16
- "typecheck": "tsc --noEmit",
17
- "vectors": "node scripts/generate_golden_vectors.mjs"
11
+ "vectors": "tsc && node vectors/generate.mjs"
18
12
  },
19
13
  "repository": {
20
14
  "type": "git",
@@ -47,14 +41,9 @@
47
41
  "astronomy-engine": "^2.1.19"
48
42
  },
49
43
  "devDependencies": {
50
- "@babel/core": "^7.26.9",
51
- "@babel/preset-env": "^7.26.9",
52
44
  "@types/jest": "^29.5.14",
53
45
  "@types/node": "^22.13.9",
54
- "babel-jest": "^29.7.0",
55
- "clean-jsdoc-theme": "^4.3.0",
56
46
  "jest": "^29.7.0",
57
- "jsdoc": "^4.0.4",
58
47
  "ts-jest": "^29.2.6",
59
48
  "typescript": "^5.8.2"
60
49
  }
@@ -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,4DAA4D;IAC5D,cAAc,EAAE,CAAC,EAAE;IACnB,4DAA4D;IAC5D,oBAAoB,EAAE,CAAC;CACjB,CAAC;AAkDX;;GAEG;AACH,MAAM,UAAU,GAAyD,IAAI,GAAG,EAAE,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IAC/B,UAAU,CAAC,KAAK,EAAE,CAAC;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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°) */
31
- readonly longitude: number;
32
- /** Current natural year (year 001: winter solstice 2012 > winter solstice 2013) */
33
- readonly year: number;
34
- /** Current moon (month) in the natural year (1-14) */
35
- readonly moon: number;
36
- /** Current week of the natural year (1-53) */
37
- readonly week: number;
38
- /** Current week within the current moon (1-4) */
39
- readonly weekOfMoon: number;
40
- /** Number of days passed since END_OF_ARTIFICIAL_TIME */
41
- readonly day: number;
42
- /** Current day of the natural year (1-366) */
43
- readonly dayOfYear: number;
44
- /** Current day of the moon (1-28) */
45
- readonly dayOfMoon: number;
46
- /** Current day of the week (1-7) */
47
- readonly dayOfWeek: number;
48
- /** True if current day is a rainbow day (day beyond the 13 moons) */
49
- readonly isRainbowDay: boolean;
50
- /** Current time in natural degrees (0-360°) */
51
- readonly time: number;
52
- /** Beginning of the natural year at the current longitude (UNIX timestamp) */
53
- readonly yearStart: number;
54
- /** Number of days in the current natural year (365 or 366) */
55
- readonly yearDuration: number;
56
- /** Beginning of the current natural day at the current longitude (UNIX timestamp) */
57
- readonly nadir: number;
58
- /**
59
- * Creates a new natural date instance.
60
- *
61
- * Converts a Gregorian date to natural time based on the specified longitude.
62
- * The longitude is used to adjust the natural time for the local position on Earth.
63
- *
64
- * @param date - JavaScript Date object, Unix timestamp, or date string
65
- * @param longitude - Longitude in degrees (-180 to 180)
66
- * @throws {Error} If inputs are invalid
67
- *
68
- * @example
69
- * // Create a natural date for the current time in Paris (longitude 2.3522)
70
- * const parisNaturalDate = new NaturalDate(new Date(), 2.3522);
71
- *
72
- * @example
73
- * // Create a natural date for a specific time in Tokyo (longitude 139.6503)
74
- * const tokyoNaturalDate = new NaturalDate('2023-06-21T12:00:00', 139.6503);
75
- */
76
- constructor(date: Date | number | string | null | undefined, longitude?: number);
77
- /**
78
- * Gets the time of an astronomical event in natural degrees.
79
- *
80
- * Converts an event timestamp to natural degrees (0-360°) within the current natural day.
81
- * Returns false if the event occurs outside the current natural day.
82
- *
83
- * This is useful for calculating the position of celestial events like sunrise, sunset,
84
- * moonrise, or moonset within the natural time system.
85
- *
86
- * @param event - Event timestamp (Date object, Unix timestamp, or date string)
87
- * @returns Event time in natural degrees (0-360°) or false if out of range
88
- *
89
- * @example
90
- * // Calculate sunrise time in natural degrees
91
- * const naturalDate = new NaturalDate(new Date(), 0);
92
- * const sunrise = '2023-01-01T06:00:00'; // Example sunrise at 6:00 AM
93
- * const sunriseInDegrees = naturalDate.getTimeOfEvent(sunrise);
94
- * console.log(`Sunrise occurs at ${sunriseInDegrees}°`);
95
- */
96
- getTimeOfEvent(event: Date | number | string): number | false;
97
- /**
98
- * Exports current date as a full ISO formatted string.
99
- *
100
- * The format is: "YYY)MM)DD TTT°DD NT±LLL.L"
101
- * - YYY: Natural year (padded to 3 digits)
102
- * - MM: Moon number (padded to 2 digits)
103
- * - DD: Day of moon (padded to 2 digits)
104
- * - TTT: Time in degrees (padded to 3 digits)
105
- * - DD: Decimal degrees (2 digits)
106
- * - ±LLL.L: Longitude with sign and 1 decimal
107
- *
108
- * @returns {string} Formatted natural date string
109
- */
110
- toString(): string;
111
- /**
112
- * Exports the date part of the natural date.
113
- *
114
- * @param separator - Separator character between components (default: ')')
115
- * @returns Formatted date string
116
- */
117
- toDateString(separator?: string): string;
118
- /**
119
- * Exports the time part of the natural date.
120
- *
121
- * @param decimals - Number of decimal places for time (default: 2)
122
- * @param rounding - Rounding increment for time (default: 1)
123
- * @returns Formatted time string
124
- */
125
- toTimeString(decimals?: number, rounding?: number): string;
126
- /**
127
- * Exports the longitude part of the natural date.
128
- *
129
- * @param decimals - Number of decimal places for longitude (default: 1)
130
- * @returns Formatted longitude string
131
- */
132
- toLongitudeString(decimals?: number): string;
133
- /**
134
- * Exports the year part of the natural date.
135
- *
136
- * @returns Formatted year string
137
- */
138
- toYearString(): string;
139
- /**
140
- * Exports the moon part of the natural date.
141
- *
142
- * @returns Formatted moon string
143
- */
144
- toMoonString(): string;
145
- /**
146
- * Exports the day of moon part of the natural date.
147
- *
148
- * @returns Formatted day of moon string
149
- */
150
- toDayOfMoonString(): string;
151
- }
152
- /**
153
- * Clears the internal year context cache.
154
- * Exposed for testing or advanced usage without exposing the cache itself.
155
- */
156
- export declare function resetYearContextCache(): void;