Skip to content

Instantly share code, notes, and snippets.

@gustavofranke
Created October 18, 2020 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavofranke/907dc30af2ba05d92ba1468d19435d09 to your computer and use it in GitHub Desktop.
Save gustavofranke/907dc30af2ba05d92ba1468d19435d09 to your computer and use it in GitHub Desktop.
-- stack repl --package <package-name>
-- stack repl --package time
> import Data.Time
Data.Time> getCurrentTime
2020-10-17 15:03:15.521782 UTC
Data.Time> utctDay <$> getCurrentTime
2020-10-17
Data.Time> today <- utctDay <$> getCurrentTime
Data.Time> today
2020-10-17
Data.Time> today0 = utctDay <$> getCurrentTime
Data.Time> today0
2020-10-17
Data.Time> toGregorian today
(2020,10,17)
Data.Time> parseTimeM True defaultTimeLocale "%Y-%m-%d" "2019-08-31" :: Maybe Day
Just 2019-08-31
Data.Time> parseTimeM True defaultTimeLocale "%Y-%m-%d" "asdf" :: Maybe Day
Nothing
Data.Time> addDays 3 today
2020-10-20
Data.Time> addGregorianMonthsClip 6 today
2021-04-17
Data.Time> addGregorianYearsClip 1 today
2021-10-17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment