exercism/elixir/library-fees/HINTS.md

2.3 KiB

Hints

General

1. Parse the stored datetimes

  • There is a built-in function that parses an ISO8601 datetime string and returns a NaiveDateTime struct.

2. Determine if a book was checked out before noon

  • You can define a Time literal using the ~T sigil.
  • There is a built-in function that changes a NaiveDateTime struct to a Time struct.
  • There is a built-in function that checks which one of two Time structs is bigger.

3. Calculate the return date

  • A day has 24 * 60 * 60 seconds.
  • There is a built-in function that adds a given number of seconds to a NaiveDateTime struct.
  • There is a built-in function that changes a NaiveDateTime struct to a Date struct.

4. Determine how late the return of the book was

  • There is a built-in function that changes a NaiveDateTime struct to a Date struct.
  • There is a built-in function that calculates the difference in days between two Date structs.

5. Determine if the book was returned on a Monday

6. Calculate the late fee

  • Combine together all of the functions that you defined in previous steps.