[erlang-questions] strftime for formatting dates and times

Masklinn masklinn@REDACTED
Wed Jun 22 10:49:13 CEST 2011

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

More information about the erlang-questions mailing list