Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatted date #239

Open
donat-b opened this issue Jun 6, 2017 · 5 comments
Open

Formatted date #239

donat-b opened this issue Jun 6, 2017 · 5 comments

Comments

@donat-b
Copy link

donat-b commented Jun 6, 2017

What is the preferred way to get formatted date (e.g. date +%F in shell)?
Thanks.

@Gabriella439
Copy link
Owner

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

@donat-b
Copy link
Author

donat-b commented Jun 7, 2017

Hmm, how about ISO 8601? I'm mostly interested in YYYY-MM-DDThh:mm:ss representation.

@3noch
Copy link

3noch commented Jun 7, 2017

Technically that is an ISO 8601-compliant format.

@donat-b
Copy link
Author

donat-b commented Jun 7, 2017

Well, yeah. But I think it makes sense to add more atomic control over format, for instance, showing just date or time.

@Gabriella439
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants