turtle
turtle copied to clipboard
Formatted date
What is the preferred way to get formatted date (e.g. date +%F
in shell)?
Thanks.
turtle
provides some default date/time formatting with the Turtle.Format.utc
format specifier. Here's an example of how you could use it:
{-# LANGUAGE OverloadedStrings #-}
import Turtle
main :: IO ()
main = do
d <- date
printf (utc%"\n") d
That formats the date using the following format which just uses the default Show
implementation for UTCTime
2017-06-07 17:14:33.278543 UTC
If you have other date/time formats in mind that you'd like turtle
to support just let me know
Hmm, how about ISO 8601? I'm mostly interested in YYYY-MM-DDThh:mm:ss representation.
Technically that is an ISO 8601-compliant format.
Well, yeah. But I think it makes sense to add more atomic control over format, for instance, showing just date or time.
So I can provide an iso8601
format specifier to make the date-time format explicit, but I think for anything more complex than that you should use the Data.Time.Format
module directly:
https://hackage.haskell.org/package/time-1.8.0.2/docs/Data-Time-Format.html