I've tried several things I could find online to print the current time as an ISO8601 string, but none of them have worked:
This SO answer assumes you already know how to get the current time, but I can't figure that out.
I keep on getting an error
Could not find module ‘System.Locale’
because it seems likeSystem.Locale
is deprecated/not installed by default anymore?I tried installing
old-local
but that just gave me new errors, I think caused by incompatibilities betweentime
andold-locale
:• Couldn't match expected type ‘time-1.9.3:Data.Time.Format.Locale.TimeLocale’ with actual type ‘System.Locale.TimeLocale’ NB: ‘time-1.9.3:Data.Time.Format.Locale.TimeLocale’ is defined in ‘Data.Time.Format.Locale’ in package ‘time-1.9.3’ ‘System.Locale.TimeLocale’ is defined in ‘System.Locale’ in package ‘old-locale-1.0.0.7’ • In the first argument of ‘formatTime’, namely ‘defaultTimeLocale’ In the expression: formatTime defaultTimeLocale "%FT%T%QZ" In an equation for ‘iso8601’: iso8601 = formatTime defaultTimeLocale "%FT%T%QZ" | 49 | iso8601 = formatTime defaultTimeLocale "%FT%T%QZ" | ^^^^^^^^^^^^^^^^^
This wiki page gets the current time, but doesn't format it as ISO8601.
this blog post seems really good, but only has one section on formatting which is actually the same as 1.:
Prelude Data.Time> formatTime defaultTimeLocale "%T, %F (%Z)" myTime
What I want, is to be able to call a function have it print out the current time as an ISO8601 string. I'm guessing this will have to actually be an IO action since it's not a strict function.