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

Idea: Suppress leading space for, e.g., "3:00pm" ? #8

Closed
jgn opened this issue Jul 28, 2011 · 5 comments
Closed

Idea: Suppress leading space for, e.g., "3:00pm" ? #8

jgn opened this issue Jul 28, 2011 · 5 comments

Comments

@jgn
Copy link

jgn commented Jul 28, 2011

I wonder if the leading space in the output could be suppressed for a format such as "3:00pm"?

ruby-1.9.2-p180 :003 > Time.now.stamp("3:00pm")
=> " 9:55am"
ruby-1.9.2-p180 :004 >

@jeremyw
Copy link
Owner

jeremyw commented Jul 28, 2011

It may be possible but would take some work. The issue is that strftime includes the space for single digit values with %l (for hour) and %e (for day of month). Stamp is simply inheriting the strftime behavior.

@mulder
Copy link

mulder commented Nov 16, 2011

What about %1I ?? that should suppress the leading space or 0.

@jeremyw
Copy link
Owner

jeremyw commented Dec 11, 2011

@tuker @mulder Nice, it looks like %1I (that's a capital 'eye') works the same as %-I, suppressing the leading space.

If you didn't catch it, this Bostonrb thread goes over it... http://groups.google.com/group/boston-rubygroup/browse_thread/thread/157927fdf102b93e/39b1b10aa3d3fbeb

I'd love to update Stamp to use this (if available in whatever Ruby you're using) but haven't had a real issue with the leading space myself yet. Ultimately I'd like to decouple Stamp from strftime.

@scottmartin
Copy link

Just incase anyone else needs this functionality right now and they don't know about squeeze, I've just been passing my formatted timestamps through it like date.stamp('Jan 1, 2000 at 1:59 PM').squeeze(' '). I didn't even know about squeeze until recently myself.

http://ruby-doc.org/core-1.9.3/String.html#method-i-squeeze

@jeremyw
Copy link
Owner

jeremyw commented Dec 13, 2012

With help from @kbrock, we've decoupled stamp from strftime, which eliminates the leading space behavior. This is currently on the rip-strftime branch, and I plan to merge to master and release a new version of the gem soon.

@jeremyw jeremyw closed this as completed Dec 13, 2012
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

4 participants