|
https://github.com/kennystone/strftimerl
I literally copied ruby's strftime docs into the readme and implemented (almost) each type of formatting.
I'm considering patching the calendar module with this functionality. Thoughts? strftime:f(now(), "Printed on %m/%d/%Y"). %=> "Printed on 11/19/2007"
strftime:f(now(), "at %I:%M%p"). %=> "at 08:37AM" strftime:f(now(), "at %I:%M%p", universal). %=> "at 02:37PM"
strftime:f(now(), "%D-%T.%N"). %=> "11/19/2007-08:38:02.445443" -Kenny
_______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
Would love this being integrated into calendar! (Or appropriate module,
although I think calendar should be the one) Cheers, Adam Kenny Stone wrote: > https://github.com/kennystone/strftimerl > > I literally copied ruby's strftime docs into the readme and implemented > (almost) each type of formatting. > > I'm considering patching the calendar module with this functionality. > Thoughts? > > strftime:f(now(), "Printed on %m/%d/%Y"). %=> "Printed on 11/19/2007" > strftime:f(now(), "at %I:%M%p"). %=> "at 08:37AM" > strftime:f(now(), "at %I:%M%p", universal). %=> "at 02:37PM" > strftime:f(now(), "%D-%T.%N"). %=> > "11/19/2007-08:38:02.445443" > > -Kenny > > _______________________________________________ > erlang-questions mailing list > [hidden email] > http://erlang.org/mailman/listinfo/erlang-questions erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
+1 for adding it to calendar (I keep having to use some partial solution)
Are you planning to do a parser also (parse date string to datetime tuple)? That would really make it complete. Zsolt
On Tue, Jun 21, 2011 at 11:28 AM, Adam Lindberg <[hidden email]> wrote: Would love this being integrated into calendar! (Or appropriate module, although I think calendar should be the one) _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
Jinx :)
https://github.com/daleharvey/dh_date/blob/master/src/dh_date.erl (date formatter + parser) Cheers Dale
On 21 June 2011 18:20, Zsolt Keszthelyi <[hidden email]> wrote: +1 for adding it to calendar (I keep having to use some partial solution) _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
In reply to this post by Adam Lindberg-4
On 2011-06-21 17:28, Adam Lindberg wrote:
> Would love this being integrated into calendar! (Or appropriate module, > although I think calendar should be the one) I like this also and I probably would want something similar folded into calendar or another module. * Abit of topic * This weekend a wrote something similar looking at python, ruby and perl api:s for datetime, time and calendar functionality. Trying to get a feel for what would be ok. However, most of those api:s are emulations of standard C time conversions. gmtime, mktime, localtime etc. Horrible horrible syntax in my opinion. On the other hand it is rather familiar. Why would you look on something like this? Well conversion between timezones, utc, epochs, dst and such would really be great to have. And i do not think calendar will suffice for this. For instance, should we have a #time{} record instead of {{Y,Mon,D},{H,Min,S}} :: datetime()? -record(time, { year :: integer(), month :: 1..12, mday :: 1..31, hour :: 0..23, min :: 0..59, sec :: 0..60, wday :: 1..7, yday :: 1..366, is_dst :: -1 | 0 | 1 }). Or what would suffice? and timezones? Just some thoughts. // Björn-Egil > > Cheers, > Adam > > > > Kenny Stone wrote: >> https://github.com/kennystone/strftimerl >> >> I literally copied ruby's strftime docs into the readme and implemented >> (almost) each type of formatting. >> >> I'm considering patching the calendar module with this functionality. >> Thoughts? >> >> strftime:f(now(), "Printed on %m/%d/%Y"). %=> "Printed on 11/19/2007" >> strftime:f(now(), "at %I:%M%p"). %=> "at 08:37AM" >> strftime:f(now(), "at %I:%M%p", universal). %=> "at 02:37PM" >> strftime:f(now(), "%D-%T.%N"). %=> >> "11/19/2007-08:38:02.445443" >> >> -Kenny >> >> _______________________________________________ >> erlang-questions mailing list >> [hidden email] >> http://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > [hidden email] > http://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
In reply to this post by Kenny Stone
# Kenny Stone 2011-06-21:
> https://github.com/kennystone/strftimerl > > I literally copied ruby's strftime docs into the readme and implemented (almost) each type of > formatting. > > I'm considering patching the calendar module with this functionality. Thoughts? > > strftime:f(now(), "Printed on %m/%d/%Y"). %=> "Printed on 11/19/2007" > strftime:f(now(), "at %I:%M%p"). %=> "at 08:37AM" > strftime:f(now(), "at %I:%M%p", universal). %=> "at 02:37PM" > strftime:f(now(), "%D-%T.%N"). %=> "11/19/2007-08:38:02.445443" Yet another weird formatting DSL for something that is more conveniently done as iolists using calendar and perhaps a few helper functions. Oh boy, am I a killjoy... The timezone/dst/etc conversion API mentioned in another post would be lovely though, preferrably using now() and/or datetime() as primary time representations, like everything else does (just provide functions that calculate the interesting bits when you need them, no?). BR, -- Jachym _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
In reply to this post by Björn-Egil Dahlberg
On Tue, 21 Jun 2011, Björn-Egil Dahlberg wrote:
> -record(time, { > year :: integer(), > month :: 1..12, > mday :: 1..31, > hour :: 0..23, > min :: 0..59, > sec :: 0..60, > wday :: 1..7, > yday :: 1..366, > is_dst :: -1 | 0 | 1 > }). > > Or what would suffice? and timezones? > > Just some thoughts. > > // Björn-Egil > (UTC+14:00 - 2011-06-22T08:15:49+14:00) and Tonga (UTC+13:00 - 2011-06-22T07:15:49+13:00). It can also be off by half an hour/15 minutes, e.g. Venezuela (UTC-04:30 - 2011-06-21T13:45:49-04:30) and Nepal (UTC+05:45 - 2011-06-22T00:00:49+05:45). IMHO ISO 8601 notation should be an option, even though it might be a "fuzzy". Best Regards, Niclas @ Erlang/OTP _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
In reply to this post by Kenny Stone
On 2011-06-21, at 17:26 , Kenny Stone wrote: > https://github.com/kennystone/strftimerl > > I literally copied ruby's strftime docs into the readme and implemented > (almost) each type of formatting. > > I'm considering patching the calendar module with this functionality. > Thoughts? > > strftime:f(now(), "Printed on %m/%d/%Y"). %=> "Printed on 11/19/2007" > strftime:f(now(), "at %I:%M%p"). %=> "at 08:37AM" > strftime:f(now(), "at %I:%M%p", universal). %=> "at 02:37PM" > strftime:f(now(), "%D-%T.%N"). %=> > "11/19/2007-08:38:02.445443" > > -Kenny Why not implement Unicode LDML's Date Format Pattern[0] instead? A second note is that using Ruby's strftime as your base may not be a good idea: it's not compatible with BSD libc's strftime (the extensions are different), though it might match POSIX's un-extended spec. I'd suggest either sticking to POSIX's strftime or using libc's as your base, rather than Ruby's. [0] http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
In reply to this post by Björn-Egil Dahlberg
On 2011-06-21, at 19:38 , Björn-Egil Dahlberg wrote:
> On 2011-06-21 17:28, Adam Lindberg wrote: >> Would love this being integrated into calendar! (Or appropriate module, >> although I think calendar should be the one) > > I like this also and I probably would want something similar folded into calendar or another module. > > * Abit of topic * > > This weekend a wrote something similar looking at python, ruby and perl api:s for datetime, time and calendar functionality. Trying to get a feel for what would be ok. However, most of those api:s are emulations of standard C time conversions. gmtime, mktime, localtime etc. Horrible horrible syntax in my opinion. On the other hand it is rather familiar. > See also JSR-310, which was authored by Joda's original developer and is an evolution of Joda (rather than a port or direct evolution) using lessons learned from Joda. _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
|
I didn't know there was a standard for strftime implementations... I'd also never really considered it a DSL, although I can see that.
I found myself writing a lot of the same code over and over again, so I wrote a simple library. Lots of languages have this method. It's handy, simple, usable, practical; all things I like in my methods. It uses established patterns that have worked for many years over many languages and many picky developers. Also things I like... :)
2011/6/22 Masklinn <[hidden email]>
_______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions |
| Powered by Nabble | Edit this page |
