Logs: liberachat/#haskell
| 2021-06-13 03:23:37 | <janus> | and the month name surely must also be easy to get |
| 2021-06-13 03:23:51 | <janus> | dunno if it is worse to make it yourself or use old-time... |
| 2021-06-13 03:24:39 | <janus> | maybe easiest just to use https://hackage.haskell.org/package/time-1.12/docs/Data-Time-Format.html#v:formatTime |
| 2021-06-13 03:24:42 | <arahael> | Yeah, it shouldn't be that much work, I wonder how most people deal with time formatting. |
| 2021-06-13 03:24:53 | <janus> | i just use iso8601 for everything ;) |
| 2021-06-13 03:24:56 | <arahael> | Yeah, I looked at formatTime, but... How do you do the '12th"? |
| 2021-06-13 03:26:26 | <janus> | that is so english-centric, i am kinda happy it isn't in 'time' ;) i see there is https://hackage.haskell.org/package/ordinal |
| 2021-06-13 03:27:03 | <arahael> | janus: Yeah, so we're going back to "Manually, painstakingly, format it yourself, by hand". :( |
| 2021-06-13 03:28:25 | <janus> | but are you sure your users would even appreciate the ordinal form? i know i always turn it off if i can |
| 2021-06-13 03:28:52 | × | justsomeguy quits (~justsomeg@user/justsomeguy) (Quit: WeeChat 3.0.1) |
| 2021-06-13 03:29:05 | <janus> | it's not even available with strftime |
| 2021-06-13 03:29:07 | <arahael> | janus: This is going to go into the string: "Come and meet us at <location> on Saturday 12th June at 11 AM!" |
| 2021-06-13 03:29:30 | → | kiweun joins (~sheepduck@2607:fea8:2a61:4800::ea20) |
| 2021-06-13 03:29:41 | × | sheepduck quits (~sheepduck@2607:fea8:2a61:4800::ea20) (Read error: Connection reset by peer) |
| 2021-06-13 03:29:52 | <arahael> | So I was wanting to format the latter part of that string. |
| 2021-06-13 03:30:32 | × | Scotty_Trees quits (~Scotty_Tr@162-234-179-169.lightspeed.brhmal.sbcglobal.net) (Quit: Leaving) |
| 2021-06-13 03:31:29 | <qrpnxz> | rfc3339 gang |
| 2021-06-13 03:31:30 | × | ubikium quits (~ubikium@2400:2200:3f7:6d04:f545:ef78:6130:411e) (Ping timeout: 268 seconds) |
| 2021-06-13 03:31:36 | → | Lord_of_Life_ joins (~Lord@user/lord-of-life/x-2819915) |
| 2021-06-13 03:32:19 | <arahael> | qrpnxz: That's not exactly "conversational", though. |
| 2021-06-13 03:32:19 | <qrpnxz> | format you want looks like rfc1123 |
| 2021-06-13 03:32:31 | <qrpnxz> | see rfc1123 :) |
| 2021-06-13 03:32:35 | <janus> | qrpnxz: is rfc3339 a subset of iso8601? |
| 2021-06-13 03:32:46 | <janus> | looks good |
| 2021-06-13 03:32:49 | × | Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 265 seconds) |
| 2021-06-13 03:32:50 | Lord_of_Life_ | is now known as Lord_of_Life |
| 2021-06-13 03:33:18 | <qrpnxz> | i think it's supposed to be the same, there's a good SO answer on a comparison between the two. I'm team rfc because ofc that's a std i can actually read xD |
| 2021-06-13 03:33:23 | <arahael> | qrpnxz: Similar, except I want full names, and no year. :) |
| 2021-06-13 03:33:41 | <qrpnxz> | sounds like a custom format |
| 2021-06-13 03:33:42 | <qrpnxz> | gl |
| 2021-06-13 03:33:55 | <arahael> | qrpnxz: Of course, trivially supported using the likes of strftime. |
| 2021-06-13 03:34:18 | <janus> | qrpnxz: looks like neither of these have the ordinal ending https://hackage.haskell.org/package/time-http |
| 2021-06-13 03:34:20 | <qrpnxz> | janus, from SO: "RFC 3339 is listed as a profile of ISO 8601" :) https://stackoverflow.com/questions/522251/whats-the-difference-between-iso-8601-and-rfc-3339-date-formats |
| 2021-06-13 03:34:23 | <janus> | and that package includes 1123 |
| 2021-06-13 03:34:39 | <janus> | qrpnxz: right , that's what the rfc text says. dunno what a profile is |
| 2021-06-13 03:34:57 | <janus> | but i guess it is better to use that name for it since it looks like iso8601 is way too big |
| 2021-06-13 03:34:58 | → | ubikium joins (~ubikium@113x43x248x70.ap113.ftth.arteria-hikari.net) |
| 2021-06-13 03:35:02 | <qrpnxz> | probably effectively a subset |
| 2021-06-13 03:35:24 | <qrpnxz> | or an instanciation |
| 2021-06-13 03:36:47 | <qrpnxz> | another area go shines is time https://golang.org/pkg/time/#pkg-constants |
| 2021-06-13 03:37:56 | <janus> | qrpnxz: is it really shining or is it just cutting the right corners ? ;) i see a problem already when saying "MST is -07:00" like they do there |
| 2021-06-13 03:38:13 | <qrpnxz> | two different formats |
| 2021-06-13 03:38:34 | <qrpnxz> | you pick |
| 2021-06-13 03:39:25 | <janus> | right, but timezone names can change, and where does "MST" come from? what if it changes , and i give it a timestamp in a period where it had the old definition? |
| 2021-06-13 03:39:48 | <qrpnxz> | MST just marks where the timezone goes in the format |
| 2021-06-13 03:39:55 | <qrpnxz> | like Jan marks where the month goes |
| 2021-06-13 03:40:10 | <qrpnxz> | and 02 marks the day and so on |
| 2021-06-13 03:40:18 | → | ec_ joins (~ec@gateway/tor-sasl/ec) |
| 2021-06-13 03:40:31 | <qrpnxz> | you can make your own custom format string quite easily |
| 2021-06-13 03:40:37 | <janus> | ok, where does the mapping MST -> -07:00 take place? if it doesn't take place, why is MST mentioned in the docs? |
| 2021-06-13 03:41:31 | <janus> | i understand that it works in 90% of the cases, probably comes from your local olson db |
| 2021-06-13 03:41:32 | <qrpnxz> | maybe i don't understand the question. MST is GMT-0700, that's just what it is. Not sure what you are asking now |
| 2021-06-13 03:42:05 | <janus> | i am saying that it is effectively not a "pure computation" because it comes from a database that is outside of go's control |
| 2021-06-13 03:42:16 | <qrpnxz> | no it's in the lib |
| 2021-06-13 03:42:31 | <qrpnxz> | you don't have to fetch it anywhere, it's not changing |
| 2021-06-13 03:42:51 | <janus> | ok, so it can't handle DST changes then? |
| 2021-06-13 03:43:19 | <qrpnxz> | i think it does, but DST produces different timezone codes |
| 2021-06-13 03:43:36 | <qrpnxz> | like CST <-> CDT |
| 2021-06-13 03:43:48 | <qrpnxz> | both central time, but one is DST and the other isnt |
| 2021-06-13 03:44:24 | <qrpnxz> | 1:00 CST doesn't change meaning on what time of year you are in |
| 2021-06-13 03:47:27 | <arahael> | So I'm using formatTime with the format string "%d", to get the day of the month, which I then convert to an integer, so that I can then get the Ordinal suffix for it and concat it. |
| 2021-06-13 03:47:33 | <arahael> | Seems quite a lot. |
| 2021-06-13 03:48:44 | <arahael> | Oh, and stripping spaces from it... |
| 2021-06-13 03:48:52 | <arahael> | A bit of a mess. |
| 2021-06-13 03:50:02 | <arahael> | I might as well just split my input string by '-' for the date parts. |
| 2021-06-13 03:52:20 | <arahael> | Heh, Data.DateTime from datetime has this comment in the code: -- the craziness of the Haskell standard library date and time functions. |
| 2021-06-13 03:52:42 | <Cale> | arahael: That sounds crazy, why not just go directly? |
| 2021-06-13 03:52:50 | <Cale> | What are you starting with? |
| 2021-06-13 03:54:06 | <arahael> | Cale: Unbelievably, just an ISO 8601 date. |
| 2021-06-13 03:54:06 | <davean> | Yah, I mean you can just ask for the month |
| 2021-06-13 03:54:10 | <Cale> | Usually you'll want to convert your UTCTime into a LocalTime in order to get the (local) Day from it, and then you can take that apart in various ways |
| 2021-06-13 03:54:18 | → | da39a3ee_ joins (~textual@171.6.243.223) |
| 2021-06-13 03:54:36 | <Cale> | You'll need to specify which TimeZone you want to know the day in though, since otherwise it'd be ambiguous. |
| 2021-06-13 03:54:38 | <arahael> | davean: But I don't want to ask for the date, the month, the day, the name of the day, the ordinal suffix of the day, etc, when I can just infer it all from the date itself. |
| 2021-06-13 03:54:43 | <arahael> | Cale: Yeah, always local. |
| 2021-06-13 03:55:06 | <arahael> | Cale: Taking it apart seems to be the *insane* bit in Haskell, though maybe I'm looking at the wrong module. |
| 2021-06-13 03:55:13 | <davean> | arahael: except you're formating it out! |
| 2021-06-13 03:55:23 | <davean> | arahael: I think you're totally confused |
| 2021-06-13 03:55:23 | <arahael> | davean: In this particular instance, yes. |
| 2021-06-13 03:55:30 | <janus> | arahael: what do you mean by "taking it apart" ? surely the iso8601 parsing is easy since it has already been written |
| 2021-06-13 03:55:42 | <Cale> | toGregorian :: Day -> (Year, MonthOfYear, DayOfMonth) |
| 2021-06-13 03:55:52 | <Cale> | is probably what you wanted? |
| 2021-06-13 03:56:19 | <Cale> | Assuming that you're starting with a Day |
| 2021-06-13 03:56:21 | <arahael> | Cale: I completely missed that since it's already in Gregorian... Yes, that's what I want. |
| 2021-06-13 03:56:34 | <arahael> | Cale: Well, LocalTime has a Day. |
| 2021-06-13 03:56:39 | <Cale> | yeah |
| 2021-06-13 03:57:14 | <arahael> | That works nicely. :) |
| 2021-06-13 03:57:50 | × | da39a3ee5e6b4b0d quits (~textual@171.6.243.223) (Ping timeout: 245 seconds) |
| 2021-06-13 03:57:55 | <Cale> | A Day is meant to be an abstract notion of a day, and it's internally stored as the number of days since a particular day in 1858 :D |
| 2021-06-13 03:59:30 | <arahael> | Makes sense. :) But... Does it support anything other than Gregorian (or Julian, even?) |
| 2021-06-13 04:00:02 | <davean> | arahael: if you looked at how format was doing it you'd have found: |
| 2021-06-13 04:00:06 | <davean> | mapGregorian :: Format (Integer, (Int, Int)) -> Format Day |
| 2021-06-13 04:00:07 | <Cale> | There's the WeekDate stuff |
| 2021-06-13 04:00:12 | <davean> | mapGregorian = mapMFormat (\(y, (m, d)) -> fromGregorianValid y m d) (\day -> (\(y, m, d) -> Just (y, (m, d))) $ toGregorian day) |
| 2021-06-13 04:00:14 | <Cale> | which counts weeks of the year |
| 2021-06-13 04:00:27 | <janus> | toModifiedJulianDay in https://hackage.haskell.org/package/time-1.12/docs/Data-Time-Calendar.html#t:Day |
| 2021-06-13 04:00:29 | <pavonia> | What happened o that particular day? |
| 2021-06-13 04:00:34 | <pavonia> | *on |
| 2021-06-13 04:00:35 | → | fizbin joins (~fizbin@2601:8a:4080:1280:d58e:2782:3061:3fa3) |
| 2021-06-13 04:01:05 | <arahael> | davean: Where's mapGregorian? (And again, I dismissed all the 'gregorian' stuff as I didn't realise I had to convert calendarws) |
All times are in UTC.