You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// the aaYear sequence is -2, -1, 0, 1, 2 while the Gregorian years are counted era0 2, era0 1, era1 1, era1 2
71
+
letcomponents=DateComponents(era: aaYear >0?1:0,
72
+
year: aaYear >0? aaYear :abs(1- aaYear),
70
73
month:KPCAADate_GetMonth(aaDate),
71
74
day:KPCAADate_GetDay(aaDate),
72
75
hour:KPCAADate_GetHour(aaDate),
@@ -79,6 +82,20 @@ public extension JulianDay {
79
82
return date
80
83
}
81
84
85
+
/// Returns the astronomical year count of this Julian Day value. The year before 1 is returned as 0, the year before 0 returned as -1.
86
+
/// This astronomical counting differs from the Gregorian year where the year before year 1 is 1BC.
87
+
/// The reason to offer this separate attribute is the difficulty of extracting the year before 1 from a Swift Date object
88
+
/// and before the year equivalent to JulianDay 0, Swift Date always returns era 0 year 4712
89
+
/// and many SwiftAA functions use an intermediate conversion from a JulianDay to a Gregorian year, and will fail when used on a Swift Date object for years before 1
90
+
/// and they expect a year 0 and not the 0-skip of the Gregorian calendar.
91
+
/// This intermediate use of the Gregorian calendar in general instead of Julian Day is risky and most likely slow, but changing would require a lot of work.
0 commit comments