Arithmetic with timespans
You can add and subtract timespans to create different length timespans, and even multiply them by numbers. For example, to create a duration of three days and three hours you could do:
ddays(3) + dhours(3)
, or 3*ddays(1) + 3*dhours(1)
or even 3*(ddays(1) + dhours(1))
.
There was an eclipse over North America on 2017-08-21 at 18:26:40. It's possible to predict the next eclipse with similar geometry by calculating the time and date one Saros in the future. A Saros is a length of time that corresponds to 223 Synodic months, a Synodic month being the period of the Moon's phases, a duration of 29 days, 12 hours, 44 minutes and 3 seconds.
Do just that in this exercise!
This exercise is part of the course
Working with Dates and Times in R
Exercise instructions
- Create a duration corresponding to one Synodic Month: 29 days, 12 hours, 44 minutes and 3 seconds.
- Create a duration corresponding to one Saros by multiplying
synodic
by 223. - Add
saros
toeclipse_2017
to predict the next eclipse.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Time of North American Eclipse 2017
eclipse_2017 <- ymd_hms("2017-08-21 18:26:40")
# Duration of 29 days, 12 hours, 44 mins and 3 secs
synodic <- ___
# 223 synodic months
saros <- ___
# Add saros to eclipse_2017