-
Notifications
You must be signed in to change notification settings - Fork 22
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
Strange output when using #stamp("29/01/2013") #21
Comments
Stamp is outputting the 2-digit year, which is 13. I've been thinking about a couple ways to handle cases like this:
Any thoughts? |
Ahhh, I understand. So it seems that the issue came about here:
The first part was a day, so Stamp assumed the second part would be a year because it couldn't find any definite matches (right?). Maybe there's some room for improvement here; eg. if the day (previous_part) was two digits, and the current part is two digits, then expect the current part to be a month (unless it's obviously not, eg. if it's greater than 12). Just thinking out loud. If nothing else, option 1 would work. I didn't realise I was giving Stamp ambiguous values until I went back over the docs. |
Another example I just noticed:
|
@jeremyw I'd personally prefer solution 1 :) By the way I ended up here because I had the same problem as @ghiculescu
|
I think I prefer solution 1 as well but may not have time to tackle it soon. I'd love to see a pull request! |
I'm looking into it, but I think we should agree on what we would consider ambiguous. |
By the way, I found a (bad) way to overcome this issue. I've changed Stamp::Emitters::TwoDigit # emitters/composite.rb
result = ''
year_emitters = @emitters.select{|e| e.field == :year}
year_emitters.first.field = :month if year_emitters.size > 1
@emitters.each { |e| result << e.format(target).to_s }
result Implementing some mechanism similar to |
Hi, Just jumping in here because I had this idea a while back and just got around to looking it up on github to see if anyone had already done this. My idea was that you just learn a single date where all the parts are unambiguous, and I think the easiest to remember is Saturday 1st February 2003 16:05:06. Learning that one date seems easier to me than learning all the crazy date part constants crap. Thoughts on the single date idea? Also, as I'm not a Ruby guy I was thinking of implementing this in PHP and JS. Not really sure what the github protocol would be on that? Separate repos connected only by name? |
@tomhicks I'm against the "golden date" idea just because you have to remember something specific, like the |
This issue is resolved in version 0.6.0. Thanks! |
Hi. I'm calling #stamp with today's date as the parameter, and getting some weird output. It seems to work correctly when
31/12
is used as the stamp parameter, as suggested in the readme. That said, I thought I'd report it because the output -"28/13/2013"
- doesn't contain any valid months, so I'm not sure how it came about.I'm using stamp 0.5.0, rails 3.2.11, and ruby 1.9.3.
The text was updated successfully, but these errors were encountered: