Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

TylerRick opened this Issue · 3 comments

2 participants


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.


    -  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.

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


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

sweet, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.