krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

Packages/MoonriseKit/Tests/SkyEngineTests/DeltaTTests.swift

dda3950a2e0fd0cc0d97262ff3b6646d6871181b
moonrise/Packages/MoonriseKit/Tests/SkyEngineTests/DeltaTTests.swift history · blame · raw

28 lines · 1045 bytes

 1import Foundation
 2import Testing
 3@testable import SkyEngine
 4
 5private func ut(_ year: Double) -> Double { (year - 2000) * 365.24217 + 14 }
 6
 7@Test func deltaTFollowsIERS() {
 8    // IERS Bulletin A, 15 October 2026: UT1 − UTC = −0.0367 s that day and −0.198 s predicted for 2 August 2027.
 9    let now = SkyEngine.time(Date(timeIntervalSince1970: 1_792_022_400))
10    #expect(abs((now.tt - now.ut) * 86_400 - 69.221) < 0.01)
11    let eclipse = SkyEngine.time(Date(timeIntervalSince1970: 1_817_201_220))
12    #expect(abs((eclipse.tt - eclipse.ut) * 86_400 - 69.382) < 0.01)
13}
14
15@Test func deltaTUnchangedOutsideModernEra() {
16    for year in [-3000.0, -500, 1000, 1700, 1900, 2000, 2010, 2050, 2100, 3000] {
17        #expect(DeltaT.seconds(ut: ut(year)) == DeltaT.polynomial(year))
18    }
19}
20
21@Test func deltaTHasNoSteps() {
22    var previous = DeltaT.seconds(ut: ut(2005))
23    for month in 1...(12 * 50) {
24        let next = DeltaT.seconds(ut: ut(2005 + Double(month) / 12))
25        #expect(abs(next - previous) < 0.25)
26        previous = next
27    }
28}