Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

TylerRick opened this issue Feb 12, 2013 · 3 comments

Comments

@TylerRick
Copy link

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
Copy link
Owner

samsonjs commented Mar 7, 2013

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

@samsonjs
Copy link
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.

@TylerRick
Copy link
Author

sweet, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants