Basic date/time question.

  • Thread starter Jean-nicolas Jolivet
  • Start date
J

Jean-nicolas Jolivet

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...
 
R

Rob Biedenharn

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://agileconsultingllc.com
(e-mail address removed)
 
J

Jean-nicolas Jolivet

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"...
 
R

Rob Biedenharn

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
 
J

Jean-nicolas Jolivet

Rob said:
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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,732
Latest member
ArronPalin

Latest Threads

Top