Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
@ 2009-12-31 14:48 Eric Sherman
  2009-12-31 19:53 ` William Morgan
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sherman @ 2009-12-31 14:48 UTC (permalink / raw)
  To: sup-devel

Here's a patch that gives the proper am/pm display for ruby1.8 if that's 
what's running.

---
 lib/sup/util.rb |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sup/util.rb b/lib/sup/util.rb
index f99e1c1..1a2a447 100644
--- a/lib/sup/util.rb
+++ b/lib/sup/util.rb
@@ -486,9 +486,9 @@ class Time
       strftime "%b %e"
     else
       if is_the_same_day? from
-        strftime("%l:%M%P")
+        (RUBY_VERSION =~ /^1.8/) ? strftime("%l:%M%p").downcase : strftime("%l:%M%P")
       elsif is_the_day_before? from
-        "Yest."  + nearest_hour.strftime("%l%P")
+        "Yest." + ((RUBY_VERSION =~ /^1.8/) ? nearest_hour.strftime("%l%p").downcase : nearest_hour.strftime("%l%P"))
       else
         strftime "%b %e"
       end
-- 
1.6.5.7
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 14:48 [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8 Eric Sherman
@ 2009-12-31 19:53 ` William Morgan
  2009-12-31 20:03   ` Eric Sherman
  0 siblings, 1 reply; 10+ messages in thread
From: William Morgan @ 2009-12-31 19:53 UTC (permalink / raw)
  To: sup-devel

Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> Here's a patch that gives the proper am/pm display for ruby1.8 if
> that's what's running.

Can you give a little more info? My ruby 1.8.7 is fine with %P. Was this
broken in earlier 1.8's?
-- 
William <wmorgan-sup@masanjin.net>
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 19:53 ` William Morgan
@ 2009-12-31 20:03   ` Eric Sherman
  2009-12-31 20:14     ` William Morgan
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sherman @ 2009-12-31 20:03 UTC (permalink / raw)
  To: sup-devel

Excerpts from William Morgan's message of Thu Dec 31 14:53:53 -0500 2009:
> Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> > Here's a patch that gives the proper am/pm display for ruby1.8 if
> > that's what's running.
> 
> Can you give a little more info? My ruby 1.8.7 is fine with %P. Was this
> broken in earlier 1.8's?

%P in 1.8.7 displays a literal "P" always, whereas %P in 1.9 display am/pm.

%p in both 1.8.7 and 1.9 displays AM/PM.

ruby1.8.7 strftime: http://ruby-doc.org/core-1.8.7/classes/Time.html#M000139
ruby1.9 strftime: http://ruby-doc.org/core-1.9/classes/Time.html#M000314

I didn't notice it until someone else mentioned it.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 20:03   ` Eric Sherman
@ 2009-12-31 20:14     ` William Morgan
  2009-12-31 21:03       ` Eric Sherman
  0 siblings, 1 reply; 10+ messages in thread
From: William Morgan @ 2009-12-31 20:14 UTC (permalink / raw)
  To: sup-devel

Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> %P in 1.8.7 displays a literal "P" always, whereas %P in 1.9 display am/pm.

That's not the case for me. I get an am/pm for 1.8.7 patch levels 174
and 72 (the two I have on hand). Unless there's some weird Debian
patching going on.

Can anyone else confirm?
-- 
William <wmorgan-sup@masanjin.net>
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 20:14     ` William Morgan
@ 2009-12-31 21:03       ` Eric Sherman
  2009-12-31 21:27         ` Benoît PIERRE
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sherman @ 2009-12-31 21:03 UTC (permalink / raw)
  To: sup-devel

Excerpts from William Morgan's message of Thu Dec 31 15:14:50 -0500 2009:
> Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> > %P in 1.8.7 displays a literal "P" always, whereas %P in 1.9 display am/pm.
> 
> That's not the case for me. I get an am/pm for 1.8.7 patch levels 174
> and 72 (the two I have on hand). Unless there's some weird Debian
> patching going on.
> 
> Can anyone else confirm?

Here's a simple test for others to try:

    $ ruby --version
    ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
    $ irb
    irb(main):001:0> RUBY_VERSION
    => "1.8.7"
    irb(main):002:0> Time.now().strftime("%l:%M%P")
    => " 3:58P"
    irb(main):003:0> quit
    $ ruby1.9 --version
    ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10]
    $ irb1.9 irb(main):001:0> RUBY_VERSION
    => "1.9.1"
    irb(main):002:0> Time.now().strftime("%l:%M%P")
    => " 3:58pm"
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 21:03       ` Eric Sherman
@ 2009-12-31 21:27         ` Benoît PIERRE
  2009-12-31 22:10           ` Eric Sherman
  0 siblings, 1 reply; 10+ messages in thread
From: Benoît PIERRE @ 2009-12-31 21:27 UTC (permalink / raw)
  To: sup-devel


[-- Attachment #1.1: Type: text/plain, Size: 1396 bytes --]

Excerpts from Eric Sherman's message of Thu Dec 31 22:03:40 +0100 2009:
> Excerpts from William Morgan's message of Thu Dec 31 15:14:50 -0500 2009:
> > Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> > > %P in 1.8.7 displays a literal "P" always, whereas %P in 1.9 display am/pm.
> > 
> > That's not the case for me. I get an am/pm for 1.8.7 patch levels 174
> > and 72 (the two I have on hand). Unless there's some weird Debian
> > patching going on.
> > 
> > Can anyone else confirm?
> 
> Here's a simple test for others to try:
> 
>     $ ruby --version
>     ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
>     $ irb
>     irb(main):001:0> RUBY_VERSION
>     => "1.8.7"
>     irb(main):002:0> Time.now().strftime("%l:%M%P")
>     => " 3:58P"
>     irb(main):003:0> quit
>     $ ruby1.9 --version
>     ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10]
>     $ irb1.9 irb(main):001:0> RUBY_VERSION
>     => "1.9.1"
>     irb(main):002:0> Time.now().strftime("%l:%M%P")
>     => " 3:58pm"

# ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]
# ruby -e 'puts Time.now().strftime("%l:%M%P")'
10:21pm

# ruby1.9 --version
ruby 1.9.0 (2008-10-04 revision 19669) [x86_64-linux]
# ruby1.9 -e 'puts Time.now().strftime("%l:%M%P")'
10:22pm

That's on Ubuntu Karmic.
-- 
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 21:27         ` Benoît PIERRE
@ 2009-12-31 22:10           ` Eric Sherman
  2010-01-01 15:13             ` William Morgan
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sherman @ 2009-12-31 22:10 UTC (permalink / raw)
  To: sup-devel

Excerpts from Benoît PIERRE's message of Thu Dec 31 16:27:41 -0500 2009:
> Excerpts from Eric Sherman's message of Thu Dec 31 22:03:40 +0100 2009:
> > Excerpts from William Morgan's message of Thu Dec 31 15:14:50 -0500 2009:
> > > Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> > > > %P in 1.8.7 displays a literal "P" always, whereas %P in 1.9 display am/pm.
> > > 
> > > That's not the case for me. I get an am/pm for 1.8.7 patch levels 174
> > > and 72 (the two I have on hand). Unless there's some weird Debian
> > > patching going on.
> > > 
> > > Can anyone else confirm?
> > 
> > Here's a simple test for others to try:
> > 
> >     $ ruby --version
> >     ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
> >     $ irb
> >     irb(main):001:0> RUBY_VERSION
> >     => "1.8.7"
> >     irb(main):002:0> Time.now().strftime("%l:%M%P")
> >     => " 3:58P"
> >     irb(main):003:0> quit
> >     $ ruby1.9 --version
> >     ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10]
> >     $ irb1.9 irb(main):001:0> RUBY_VERSION
> >     => "1.9.1"
> >     irb(main):002:0> Time.now().strftime("%l:%M%P")
> >     => " 3:58pm"
> 
> # ruby --version
> ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]
> # ruby -e 'puts Time.now().strftime("%l:%M%P")'
> 10:21pm
> 
> # ruby1.9 --version
> ruby 1.9.0 (2008-10-04 revision 19669) [x86_64-linux]
> # ruby1.9 -e 'puts Time.now().strftime("%l:%M%P")'
> 10:22pm
> 
> That's on Ubuntu Karmic.

Hmm.  Maybe this issue only exists on OSX.  I'm kind of jealous that linux 
rubies get features from the future!  I first heard about this AM/PM 
behavior from [this][1] sup-talk thread and hadn't noticed it myself until 
then.

[1]: http://rubyforge.org/pipermail/sup-talk/2009-December/003599.html
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2009-12-31 22:10           ` Eric Sherman
@ 2010-01-01 15:13             ` William Morgan
  2010-01-02  5:59               ` Blake Burkhart
  0 siblings, 1 reply; 10+ messages in thread
From: William Morgan @ 2010-01-01 15:13 UTC (permalink / raw)
  To: sup-devel

Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> Hmm.  Maybe this issue only exists on OSX.

I suspect so. Can you provide a patch that uses the downcase trick and
doesn't check for the ruby version or the OS? (Maybe with a helpful
comment.) That should work everywhere, lame as it may be.
-- 
William <wmorgan-sup@masanjin.net>
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2010-01-01 15:13             ` William Morgan
@ 2010-01-02  5:59               ` Blake Burkhart
  2010-01-02  6:13                 ` Eric Sherman
  0 siblings, 1 reply; 10+ messages in thread
From: Blake Burkhart @ 2010-01-02  5:59 UTC (permalink / raw)
  To: sup-devel

Excerpts from William Morgan's message of Fri Jan 01 09:13:08 -0600 2010:
> Reformatted excerpts from Eric Sherman's message of 2009-12-31:
> > Hmm.  Maybe this issue only exists on OSX.
> 
> I suspect so. Can you provide a patch that uses the downcase trick and
> doesn't check for the ruby version or the OS? (Maybe with a helpful
> comment.) That should work everywhere, lame as it may be.

I don't know if you need any more examples of this, but I'm running Mac OS
10.6, and can reproduce this with the three different versions of ruby I
happen to have installed.

Apple supplied ruby:
$ /usr/bin/ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ /usr/bin/ruby -e 'puts Time.now().strftime("%l:%M%P")'
11:27P

Ruby from the MacPorts package manager, patchlevel 174:
$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
$ ruby -e 'puts Time.now().strftime("%l:%M%P")'
11:25P

And [MacRuby][1], which is completely beta everything, but is 1.9:
$ macruby --version
MacRuby version 0.5 (ruby 1.9.0) [universal-darwin10.0, x86_64]
$ macruby -e 'puts Time.now().strftime("%l:%M%P")'
11:25P

I'm pretty sure that *should* work on MacRuby, but it's not. I think that's
possibly their fault though. I guess I could report it as a bug to them then.
I'm not really using that ruby version for anything, so I don't know how
complete it is.

[1]: http://www.macruby.org/

-- 
Blake Burkhart
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8
  2010-01-02  5:59               ` Blake Burkhart
@ 2010-01-02  6:13                 ` Eric Sherman
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Sherman @ 2010-01-02  6:13 UTC (permalink / raw)
  To: sup-devel

Excerpts from Blake Burkhart's message of Sat Jan 02 00:59:08 -0500 2010:
> Excerpts from William Morgan's message of Fri Jan 01 09:13:08 -0600 2010:
> > I suspect so. Can you provide a patch that uses the downcase trick and
> > doesn't check for the ruby version or the OS? (Maybe with a helpful
> > comment.) That should work everywhere, lame as it may be.
> 
> And [MacRuby][1], which is completely beta everything, but is 1.9:
> $ macruby --version
> MacRuby version 0.5 (ruby 1.9.0) [universal-darwin10.0, x86_64]
> $ macruby -e 'puts Time.now().strftime("%l:%M%P")'
> 11:25P
> 
> I'm pretty sure that *should* work on MacRuby, but it's not. I think that's
> possibly their fault though. I guess I could report it as a bug to them then.
> I'm not really using that ruby version for anything, so I don't know how
> complete it is.
> 
> [1]: http://www.macruby.org/

I've resubmitted the patch in a new thread titled "[PATCH] fixed am/pm 
display for ruby 1.8 darwin (v2)", but like William says it should work 
everywhere including MacRuby because it just emulate's %P by downcase()ing 
%p.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-01-02  6:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-31 14:48 [sup-devel] [PATCH] fixed am/pm in thread-list-mode for ruby1.8 Eric Sherman
2009-12-31 19:53 ` William Morgan
2009-12-31 20:03   ` Eric Sherman
2009-12-31 20:14     ` William Morgan
2009-12-31 21:03       ` Eric Sherman
2009-12-31 21:27         ` Benoît PIERRE
2009-12-31 22:10           ` Eric Sherman
2010-01-01 15:13             ` William Morgan
2010-01-02  5:59               ` Blake Burkhart
2010-01-02  6:13                 ` Eric Sherman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox