Add option (%-) to not pad days and hours #18

Closed
TylerRick opened this Issue Feb 12, 2013 · 3 comments

Projects

None yet

2 participants

@TylerRick

In Ruby, I like to use this format:

Time::DATE_FORMATS[:day_name_long_at_time] = "%A, %B %-d, %Y, at %-I:%M %P"

Which gives me nice human-readable times like this:

'Thursday, October 4, 2012, at 5:00 pm'

I don't know if you're aiming for full feature parity with Ruby's strftime (probably not), but I noticed you had added some other nice Ruby extensions so I'm hoping you'll add this one.... because really, who wants to have their dates formatted as October 04 instead of October 4? :)

Here's the relevant section of ri strftime:

  The directive consists of a percent (%) character,
  zero or more flags, optional minimum field width,
  optional modifier and a conversion specifier
  as follows.

    %<flags><width><modifier><conversion>

  Flags:
    -  don't pad a numerical output.
    _  use spaces for padding.
    0  use zeros for padding.
    ^  upcase the result string.
    #  change case.
    :  use colons for %z.
@samsonjs
Owner
samsonjs commented Mar 7, 2013

Good suggestion. I will add a couple of these, %- and %_ for sure, probably %0 and %^ as well.

@samsonjs
Owner
samsonjs commented Mar 8, 2013

Just a note that %e is equivalent to %-d and %l (lowercase L) is like %-I except it includes the space. Might be a useful workaround.

I am going to try and implement this tonight though, so you may not have to use them.

@samsonjs samsonjs closed this in 71af5de Mar 8, 2013
@TylerRick

sweet, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment