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/MarsTimeTests.swift

04b2b1d914788057bcd20945b876847386eb8f65
moonrise/Packages/MoonriseKit/Tests/SkyEngineTests/MarsTimeTests.swift history · blame · raw

24 lines · 1006 bytes

3 symbols in this file
 1import Foundation
 2import Testing
 3@testable import SkyEngine
 4
 5@Test func msdReferenceEpoch() {
 6    // Allison & McEwen (2000): MSD 44796.0 at about 2000-01-06 00:00 TT.
 7    let tt = Date(timeIntervalSince1970: 947_116_800 - 69.184)
 8    #expect(abs(MarsTime.msd(tt) - 44796.0) < 0.001)
 9}
10
11@Test func landingDaysAreSolZero() throws {
12    let perseverance = try #require(MarsTime.Rover.active.first { $0.name == "Perseverance" })
13    let curiosity = try #require(MarsTime.Rover.active.first { $0.name == "Curiosity" })
14    #expect(MarsTime.sol(utc("2021-02-18T20:55:00Z"), rover: perseverance) == 0)
15    #expect(MarsTime.sol(utc("2012-08-06T05:17:57Z"), rover: curiosity) == 0)
16    // One sol is 88,775.244 s.
17    #expect(MarsTime.sol(utc("2021-02-18T20:55:00Z").addingTimeInterval(88_775.244), rover: perseverance) == 1)
18}
19
20@Test func localTimeIsWithinADay() {
21    let t = MarsTime.localMeanTime(.now, eastLongitude: 77.45)
22    #expect(t >= 0 && t < 24)
23    #expect(MarsTime.format(hours: 13.5) == "13:30")
24}