[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Time.strftime 12 hour format

Stoopidboi Stoopidboi

11/29/2007 6:45:00 AM

I'm trying to display a date/time in 12-hour format. According to the
Time.strftime API (http://ruby-doc.org/core/classes/Time.ht...)
the 12-hour hour range is supposed to be [1..12]. Why am I getting
"00:13:14 PM" for the time portion when I execute the following line?

How should I write so that I'll get "12:13:14 PM" instead?

Time.local(2007, 'nov', 27, 12, 13, 14).strftime("%Y-%m-%d %I:%M:%S %p")
--
Posted via http://www.ruby-....

20 Answers

Justin Collins

11/29/2007 7:41:00 AM

0

Stoopidboi Stoopidboi wrote:
> I'm trying to display a date/time in 12-hour format. According to the
> Time.strftime API (http://ruby-doc.org/core/classes/Time.ht...)
> the 12-hour hour range is supposed to be [1..12]. Why am I getting
> "00:13:14 PM" for the time portion when I execute the following line?
>
> How should I write so that I'll get "12:13:14 PM" instead?
>
> Time.local(2007, 'nov', 27, 12, 13, 14).strftime("%Y-%m-%d %I:%M:%S %p")
>
I copy-pasted this into IRB and it worked just fine:

irb(main):001:0> Time.local(2007, 'nov', 27, 12, 13,
14).strftime("%Y-%m-%d %I:%M:%S %p")
=> "2007-11-27 12:13:14 PM"

ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-linux]

-Justin

Jacob Dunphy

11/29/2007 8:47:00 AM

0

As another quick note...

irb(main):010:0> Time.local(2007, 'nov', 27, 4, 13, 14).strftime("%Y-
%m-%d %I:%M:%S %p")
=> "2007-11-27 04:13:14 AM"

irb(main):009:0> Time.local(2007, 'nov', 27, 4, 13, 14).strftime("%Y-
%m-%d %l:%M:%S %p")
=> "2007-11-27 4:13:14 AM"

Using %l instead of %I for hours drops the leading zero.


On Nov 28, 11:40 pm, Justin Collins <justincoll...@ucla.edu> wrote:
> Stoopidboi Stoopidboi wrote:
> > I'm trying to display a date/time in 12-hour format. According to the
> > Time.strftime API (http://ruby-doc.org/core/classes/Time.ht...)
> > the 12-hour hour range is supposed to be [1..12]. Why am I getting
> > "00:13:14 PM" for the time portion when I execute the following line?
>
> > How should I write so that I'll get "12:13:14 PM" instead?
>
> > Time.local(2007, 'nov', 27, 12, 13, 14).strftime("%Y-%m-%d %I:%M:%S %p")
>
> I copy-pasted this into IRB and it worked just fine:
>
> irb(main):001:0> Time.local(2007, 'nov', 27, 12, 13,
> 14).strftime("%Y-%m-%d %I:%M:%S %p")
> => "2007-11-27 12:13:14 PM"
>
> ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-linux]
>
> -Justin

Stoopidboi Stoopidboi

11/29/2007 3:23:00 PM

0

Sorry to waste everyone's time, was a JRuby bug. Just found that it has
been fixed in latest trunk.
--
Posted via http://www.ruby-....

Your Name

11/4/2013 8:05:00 PM

0

In article <I9Rdu.15544$5S.8485@fx29.am4>, Stephen Wilson
<stephen.wilson2004nospam@ntlworld.com> wrote:

> "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
> news:l58dpg$omb$1@gallifrey.nk.ca...
> >>
> >>
> >>20 days and counting.
> >>
> >>Is John Hurt really the Valeyard?
>
> No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
> Eccleston).
<snip>

Still spouting your own imaginary belief and wishful thinking as though
it was a fact I see. :-
The real fact is that we have no idea who or what John Hurt is playing
and won't until the Anniversary Special is played in a couple of weeks.

doctor

11/4/2013 8:11:00 PM

0

In article <051120130904508336%YourName@YourISP.com>,
Your Name <YourName@YourISP.com> wrote:
>In article <I9Rdu.15544$5S.8485@fx29.am4>, Stephen Wilson
><stephen.wilson2004nospam@ntlworld.com> wrote:
>
>> "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
>> news:l58dpg$omb$1@gallifrey.nk.ca...
>> >>
>> >>
>> >>20 days and counting.
>> >>
>> >>Is John Hurt really the Valeyard?
>>
>> No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
>> Eccleston).
><snip>
>
>Still spouting your own imaginary belief and wishful thinking as though
>it was a fact I see. :->
>The real fact is that we have no idea who or what John Hurt is playing
>and won't until the Anniversary Special is played in a couple of weeks.

Further speculation: Name of the Doctor is 1/3 and Day of the Doctor
is 2/3 . The End of this is at Christmas.

My guess of a Christmas Title name: Battle of the Doctor.
--
Member - Liberal International This is doctor@nl2k.ab.ca Ici doctor@nl2k.ab.ca
God,Queen and country!Never Satan President Republic!Beware AntiChrist rising!
http://www.fullyfollow.m... Look at Psalms 14 and 53 on Atheism
23 Nov 2013 a Big day indeed

David Johnston

11/4/2013 8:12:00 PM

0

On 11/4/2013 10:52 AM, Stephen Wilson wrote:
> "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
> news:l58dpg$omb$1@gallifrey.nk.ca...
>>>
>>>
>>> 20 days and counting.
>>>
>>> Is John Hurt really the Valeyard?
>
> No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
> Eccleston).

How do you know that?

doctor

11/4/2013 8:23:00 PM

0

In article <l58v32$a0m$1@dont-email.me>,
David Johnston <David@block.net> wrote:
>On 11/4/2013 10:52 AM, Stephen Wilson wrote:
>> "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
>> news:l58dpg$omb$1@gallifrey.nk.ca...
>>>>
>>>>
>>>> 20 days and counting.
>>>>
>>>> Is John Hurt really the Valeyard?
>>
>> No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
>> Eccleston).
>
>How do you know that?
>

Exactly. Official Explanation is that he is between McGann and Eccleston.
--
Member - Liberal International This is doctor@nl2k.ab.ca Ici doctor@nl2k.ab.ca
God,Queen and country!Never Satan President Republic!Beware AntiChrist rising!
http://www.fullyfollow.m... Look at Psalms 14 and 53 on Atheism
23 Nov 2013 a Big day indeed

Your Name

11/4/2013 8:33:00 PM

0

In article <l58v32$a0m$1@dont-email.me>, David Johnston
<David@block.net> wrote:

> On 11/4/2013 10:52 AM, Stephen Wilson wrote:
> > "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
> > news:l58dpg$omb$1@gallifrey.nk.ca...
> >>>
> >>>
> >>> 20 days and counting.
> >>>
> >>> Is John Hurt really the Valeyard?
> >
> > No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
> > Eccleston).
>
> How do you know that?

He doesn't *know* anything of the kind. It's all imagination and
wishful thinking based on what he (and another fool) believe was said
in the final episode of last season, but nothing of the kind was
actually said and there's no real evidence for it - he may turn out to
be right, he may turn out to be be wrong, but spouting it as an actual
fact is simply delusional.

Ignis Fatuus

11/4/2013 8:42:00 PM

0

On Tue, 05 Nov 2013 09:33:08 +1300, Your Name <YourName@YourISP.com>
wrote:

>In article <l58v32$a0m$1@dont-email.me>, David Johnston
><David@block.net> wrote:
>
>> On 11/4/2013 10:52 AM, Stephen Wilson wrote:
>> > "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
>> > news:l58dpg$omb$1@gallifrey.nk.ca...
>> >>>
>> >>>
>> >>> 20 days and counting.
>> >>>
>> >>> Is John Hurt really the Valeyard?
>> >
>> > No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
>> > Eccleston).
>>
>> How do you know that?
>
>He doesn't *know* anything of the kind. It's all imagination and
>wishful thinking based on what he (and another fool) believe was said
>in the final episode of last season, but nothing of the kind was
>actually said and there's no real evidence for it - he may turn out to
>be right, he may turn out to be be wrong, but spouting it as an actual
>fact is simply delusional.

But it all seems abundantly clear:

Scene : Inside the Doctor's timeline. The Doctor has reached out to Clara,
and saved her from oblivion. But as the Doctor hugs her he sees a
mysterious stranger with his back turned to the couple. As the Doctor
releases his hold on Clara, she turns to see what has distracted his
attention and asks :

Clara : Who's that?
Doctor : Never mind. Lets get back.
Clara : But who is he?
Doctor : He's Me. There's only Me here, that's the point, now let's get
back.
Clara : But I never saw that one. I saw all of you, eleven faces all of
them you, you're the
eleventh Doctor.
Smith : I said he was me. I never said he was the Doctor.
Clara : I don't understand.
Smith : My name. My real name. That is not the point. The name I chose is
The Doctor. The name you choose it's like a promise you make. He's the one
who broke the promise.

(Clara Faints and falls into the Doctor's arms)

Doctor : Clara! Clara! Clara!

(The Doctor stands with the unconscious Clara in his arms)

Doctor : He Is My Secret.

nth Doctor (Hurt) : What I did, I did without choice.
Doctor : I know.
nth Doctor (Hurt) : In the name of Peace and Sanity.
Doctor (scornfully) : But not in the name of the Doctor.

(Dramatic Music. The nth Doctor turns slowly to face the camera)
(A Caption Appears)

INTRODUCING
JOHN HURT
AS
THE DOCTOR

David Johnston

11/4/2013 8:54:00 PM

0

On 11/4/2013 1:42 PM, Ignis Fatuus wrote:
> On Tue, 05 Nov 2013 09:33:08 +1300, Your Name <YourName@YourISP.com>
> wrote:
>
>> In article <l58v32$a0m$1@dont-email.me>, David Johnston
>> <David@block.net> wrote:
>>
>>> On 11/4/2013 10:52 AM, Stephen Wilson wrote:
>>>> "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message
>>>> news:l58dpg$omb$1@gallifrey.nk.ca...
>>>>>>
>>>>>>
>>>>>> 20 days and counting.
>>>>>>
>>>>>> Is John Hurt really the Valeyard?
>>>>
>>>> No he's not. John Hurt is playing the 9th Doctor (i.e. the one before
>>>> Eccleston).
>>>
>>> How do you know that?
>>
>> He doesn't *know* anything of the kind. It's all imagination and
>> wishful thinking based on what he (and another fool) believe was said
>> in the final episode of last season, but nothing of the kind was
>> actually said and there's no real evidence for it - he may turn out to
>> be right, he may turn out to be be wrong, but spouting it as an actual
>> fact is simply delusional.
>
> But it all seems abundantly clear:
>
> Scene : Inside the Doctor's timeline. The Doctor has reached out to Clara,
> and saved her from oblivion. But as the Doctor hugs her he sees a
> mysterious stranger with his back turned to the couple. As the Doctor
> releases his hold on Clara, she turns to see what has distracted his
> attention and asks :
>
> Clara : Who's that?
> Doctor : Never mind. Lets get back.
> Clara : But who is he?
> Doctor : He's Me. There's only Me here, that's the point, now let's get
> back.
> Clara : But I never saw that one. I saw all of you, eleven faces all of
> them you, you're the
> eleventh Doctor.
> Smith : I said he was me. I never said he was the Doctor.
> Clara : I don't understand.
> Smith : My name. My real name. That is not the point. The name I chose is
> The Doctor. The name you choose it's like a promise you make. He's the one
> who broke the promise.
>
> (Clara Faints and falls into the Doctor's arms)
>
> Doctor : Clara! Clara! Clara!
>
> (The Doctor stands with the unconscious Clara in his arms)
>
> Doctor : He Is My Secret.
>
> nth Doctor (Hurt) : What I did, I did without choice.
> Doctor : I know.
> nth Doctor (Hurt) : In the name of Peace and Sanity.
> Doctor (scornfully) : But not in the name of the Doctor.
>
> (Dramatic Music. The nth Doctor turns slowly to face the camera)
> (A Caption Appears)
>
> INTRODUCING
> JOHN HURT
> AS
> THE DOCTOR
>

I see nothing there that suggests he's the Ninth.