[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Basic date/time question.

Jean-nicolas Jolivet

12/19/2007 9:28:00 PM

I'm trying to calculate a period of time; basically each month is
divided in 2 periods, from the 1st of the month to the 15th is period1,
and from the 16th to the last day of the month is period2...

Now my problem is that..I'm not sure if midnight (00:00:00) is
considered the "end " of the current day, or the "start" of the next
day...

So for example; is December 15th, midnight (00:00:00) considered the
very start of December 15th, or the very end of it?

Basically, I'm not sure as to where a "day" starts and ends?
(ex: from 00:00:00 to 11:59:59? or from 00:00:01 to 00:00:00 etc..)

Any help would be appreciated.. I know it might sound a bit confusing, I
can try to explain it better...
--
Posted via http://www.ruby-....

4 Answers

Rob Biedenharn

12/19/2007 9:35:00 PM

0

On Dec 19, 2007, at 4:28 PM, Jean-nicolas Jolivet wrote:

> I'm trying to calculate a period of time; basically each month is
> divided in 2 periods, from the 1st of the month to the 15th is
> period1,
> and from the 16th to the last day of the month is period2...
>
> Now my problem is that..I'm not sure if midnight (00:00:00) is
> considered the "end " of the current day, or the "start" of the next
> day...
>
> So for example; is December 15th, midnight (00:00:00) considered the
> very start of December 15th, or the very end of it?
>
> Basically, I'm not sure as to where a "day" starts and ends?
> (ex: from 00:00:00 to 11:59:59? or from 00:00:01 to 00:00:00 etc..)
>
> Any help would be appreciated.. I know it might sound a bit
> confusing, I
> can try to explain it better...
> --


Midnight is the START of the day.

-Rob

Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com



Jean-nicolas Jolivet

12/19/2007 9:40:00 PM

0

Gotcha, so basically, using December as an example, the period1 would
be:
From: December 1, 00:00:00 (midnight)
To: December 15, 11:59:59

and Period2:
From: December 16th 00:00:00 (midnight)
To: December 31st 11:59:59

right? Just want to make sure I'm not "missing a second"...



Rob Biedenharn wrote:
> On Dec 19, 2007, at 4:28 PM, Jean-nicolas Jolivet wrote:
>
>
> Midnight is the START of the day.
>
> -Rob
>
> Rob Biedenharn http://agileconsult...
> Rob@AgileConsultingLLC.com

--
Posted via http://www.ruby-....

Rob Biedenharn

12/19/2007 10:27:00 PM

0

Or (after converting the strings to real Time objects):

period1 = ("December 1, 00:00:00"..."December 16, 00:00:00")

period2 = ("December 16, 00:00:00"..."January 1, 00:00:00")

Note the end-excluding three-dot Range constructor.

This way of thinking works with Date or Time and means that for any
given date in December, only one of these can be true:

period1.include?(given)
period2.include?(given)

-Rob

On Dec 19, 2007, at 4:39 PM, Jean-nicolas Jolivet wrote:

> Gotcha, so basically, using December as an example, the period1 would
> be:
> From: December 1, 00:00:00 (midnight)
> To: December 15, 11:59:59
>
> and Period2:
> From: December 16th 00:00:00 (midnight)
> To: December 31st 11:59:59
>
> right? Just want to make sure I'm not "missing a second"...
>
>
>
> Rob Biedenharn wrote:
>> On Dec 19, 2007, at 4:28 PM, Jean-nicolas Jolivet wrote:
>>
>>
>> Midnight is the START of the day.
>>
>> -Rob
>>
>> Rob Biedenharn http://agileconsult...
>> Rob@AgileConsultingLLC.com



Jean-nicolas Jolivet

12/19/2007 11:11:00 PM

0

Rob Biedenharn wrote:
> Or (after converting the strings to real Time objects):
>
> period1 = ("December 1, 00:00:00"..."December 16, 00:00:00")
>
> period2 = ("December 16, 00:00:00"..."January 1, 00:00:00")
>
> Note the end-excluding three-dot Range constructor.
>
> This way of thinking works with Date or Time and means that for any
> given date in December, only one of these can be true:
>
> period1.include?(given)
> period2.include?(given)
>
> -Rob


Great... makes more sense that way! Thank you :)

--
Posted via http://www.ruby-....