[Haskell-beginners] Simple data type for dates?
Matthew Low
mlow at ualberta.ca
Wed Jun 30 05:31:47 UTC 2021
The `time` package equivalent of `MyDate` would be `Day`:
storeDate :: Day
storeDate = fromGregorian 2021 6 29
> storeDate
2021-06-29
> toGregorian storeDate
(2021,6,29)
> dayOfWeek storeDate
Tuesday
However, I don't see any easy conversion between the numeric month and its
English name.
On Tue, Jun 29, 2021 at 10:58 PM Galaxy Being <borgauf at gmail.com> wrote:
> I've looked at Data.Time, but I'm not seeing examples. I'd like to figure
> out how to simply have use of similar to this:
>
> type MyMonth = String
> type MyDay = String
> type MyYear = String
> data MyDate = MyDate MyMonth MyDay MyYear deriving Show
>
> storeDate :: MyDate
> storeDate = "June" "29" "2021"
>
> which will be in a bigger data structure I'm building. I can't believe
> this isn't reinventing some long-established wheel. Is there such a type
> ready to use?
>
> ⨽
> Lawrence Bottorff
> Grand Marais, MN, USA
> borgauf at gmail.com
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210629/c48e21b3/attachment.html>
More information about the Beginners
mailing list