import Foundation
// Use Date() to get the current date and time
let now = Date()
// That is UTC. How to get time zone of user?
// Get the number of seconds since 1970 the Unix epoch
print("Date and time now \(now)")
print("Posix seconds \(now.timeIntervalSince1970)")
// Days of epoch 1970
let days = now.timeIntervalSince1970 / (3600*24)
print("Days since 1970-01-01: \(days)")
print("---")
/*
"""
Note, Julian Date Numbers can be calculated
with day offset from Posix dates
Example JDN 2460795 date 2025-04-29 Epoch day 20207
Offset = 2460794 - 20207 = 2440587 before UTC 12:00
2460795 - 20207 = 2440588 after UTC 12:00
"""
*/
let julianDay = 2440587.5 + days
let jdn = Int(julianDay)
print("Julian Day Number (JDN) = \(jdn)")
print("Julian Day (JD) = \(julianDay)")
// Posix functions got from
// https://[Log in to view URL]
To embed this project on your website, copy the following code and paste it into your website's HTML: