1. Learn
  2. /
  3. Courses
  4. /
  5. Working with Dates and Times in R

Connected

Exercise

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!

Instructions

100 XP
  • 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 to eclipse_2017 to predict the next eclipse.