summaryrefslogtreecommitdiff
path: root/CosmicCalendar.hs
diff options
context:
space:
mode:
Diffstat (limited to 'CosmicCalendar.hs')
-rw-r--r--CosmicCalendar.hs43
1 files changed, 22 insertions, 21 deletions
diff --git a/CosmicCalendar.hs b/CosmicCalendar.hs
index 50566d3..b198328 100644
--- a/CosmicCalendar.hs
+++ b/CosmicCalendar.hs
@@ -65,31 +65,35 @@ data CalendarEntry = CalendarEntry {
65} deriving (Show) 65} deriving (Show)
66 66
67-- TODO: Encode the input times like so: 67-- TODO: Encode the input times like so:
68data CosmicTime = YearsAgo Rational | YearsAfterBigBang Rational | YearsBCE Rational | YearsCE Rational 68--
69-- We need the Map data structure to have a simple ordering... 69-- data CosmicTime = YearsAgo Rational | YearsAfterBigBang Rational | YearsBCE Rational | YearsCE Rational
70-- We could simply regenerate the entire table as a function of the year. 70--
71-- This would also allow to fudge the last day countdown to be identical on leap years. 71-- The absolute time values (YearsBCE and YearsCE) will be computed using the
72-- "YearsAgo" would measure from the end of the year on a 365 day model even on 366 day years. 72-- year at program start:
73-- Another option is to keep it 365-based, but on leap years fudge every day after Feb 29 when we use the calendar... 73
74-- I.e. the getNextCalendarEntry functions would subtract a day from the input value starting March 1. 74currentYear :: Integer
75-- But this still doesn't allow to encode such dates as `YearsCE 1492` for Columbus. 75currentYear = unsafePerformIO $ getZonedTime <&> toGregorian . localDay . zonedTimeToLocalTime <&> view _1
76 76
77theCalendar :: Map NominalDiffTime CalendarEntry 77theCalendar :: Map NominalDiffTime CalendarEntry
78theCalendar = Map.fromList $ map (\x -> (calBeginTime x, x)) theCalendarList 78theCalendar = Map.fromList $ map (\x -> (calBeginTime x, x)) theCalendarList
79 79
80years :: Rational -> NominalDiffTime
81years = (* lengthOfYear) . fromRational
82
83yearsAgo :: Rational -> NominalDiffTime
84yearsAgo (fromRational -> n) = lengthOfYear * (1 - (n / fromIntegral ageOfUniverseInYears))
85
86afterBigBang :: NominalDiffTime -> NominalDiffTime
87afterBigBang = (/ ageOfUniverse) . (* lengthOfYear)
88
80thousandYears :: Rational -> NominalDiffTime 89thousandYears :: Rational -> NominalDiffTime
81thousandYears = (* (lengthOfYear * 1000)) . fromRational 90thousandYears = years . (* 1000)
82 91
83millionYears :: Rational -> NominalDiffTime 92millionYears :: Rational -> NominalDiffTime
84millionYears = (* (lengthOfYear * 1000 * 1000)) . fromRational 93millionYears = thousandYearsAgo . (* 1000)
85 94
86billionYears :: Rational -> NominalDiffTime 95billionYears :: Rational -> NominalDiffTime
87billionYears = (* (lengthOfYear * 1000 * 1000 * 1000)) . fromRational 96billionYears = millionYearsAgo . (* 1000)
88
89yearsAgo :: Rational -> NominalDiffTime
90yearsAgo (fromRational -> n) = lengthOfYear' * (1 - (n / fromIntegral ageOfUniverseInYears))
91 where
92 lengthOfYear' = 365 * lengthOfDay -- TODO: Countdown will be wrong day on leap years!
93 97
94thousandYearsAgo :: Rational -> NominalDiffTime 98thousandYearsAgo :: Rational -> NominalDiffTime
95thousandYearsAgo = yearsAgo . (* 1000) 99thousandYearsAgo = yearsAgo . (* 1000)
@@ -100,9 +104,6 @@ millionYearsAgo = thousandYearsAgo . (* 1000)
100billionYearsAgo :: Rational -> NominalDiffTime 104billionYearsAgo :: Rational -> NominalDiffTime
101billionYearsAgo = millionYearsAgo . (* 1000) 105billionYearsAgo = millionYearsAgo . (* 1000)
102 106
103afterBigBang :: NominalDiffTime -> NominalDiffTime
104afterBigBang = (/ ageOfUniverse) . (* lengthOfYear)
105
106yearStart :: LocalTime -> LocalTime 107yearStart :: LocalTime -> LocalTime
107yearStart (LocalTime d _) = LocalTime d' t' 108yearStart (LocalTime d _) = LocalTime d' t'
108 where 109 where
@@ -529,8 +530,8 @@ Named Nyasasaurus parringtoni, the roughly 243-million-year-old fossils represen
529 ] 530 ]
530 531
531 where 532 where
532 theYear = yearsAgo . (2022 -) 533 theYear = yearsAgo . toRational . (currentYear -)
533 yearsBeforeCommonEra n = yearsAgo (2022 + n) 534 yearsBeforeCommonEra = yearsAgo . toRational . ((+) (currentYear - 1))
534 earthDescription = [text| 535 earthDescription = [text|
535 The standard model for the formation of the Solar System (including the Earth) is the solar nebula hypothesis.[23] In this model, the Solar System formed from a large, rotating cloud of interstellar dust and gas called the solar nebula. It was composed of hydrogen and helium created shortly after the Big Bang 13.8 Ga (billion years ago) and heavier elements ejected by supernovae. About 4.5 Ga, the nebula began a contraction that may have been triggered by the shock wave from a nearby supernova.[24] A shock wave would have also made the nebula rotate. As the cloud began to accelerate, its angular momentum, gravity, and inertia flattened it into a protoplanetary disk perpendicular to its axis of rotation. Small perturbations due to collisions and the angular momentum of other large debris created the means by which kilometer-sized protoplanets began to form, orbiting the nebular center.[25] 536 The standard model for the formation of the Solar System (including the Earth) is the solar nebula hypothesis.[23] In this model, the Solar System formed from a large, rotating cloud of interstellar dust and gas called the solar nebula. It was composed of hydrogen and helium created shortly after the Big Bang 13.8 Ga (billion years ago) and heavier elements ejected by supernovae. About 4.5 Ga, the nebula began a contraction that may have been triggered by the shock wave from a nearby supernova.[24] A shock wave would have also made the nebula rotate. As the cloud began to accelerate, its angular momentum, gravity, and inertia flattened it into a protoplanetary disk perpendicular to its axis of rotation. Small perturbations due to collisions and the angular momentum of other large debris created the means by which kilometer-sized protoplanets began to form, orbiting the nebular center.[25]
536 537