Playing Syatem.DateTime.

  • Thread starter Thread starter Steve McLellan
  • Start date Start date
S

Steve McLellan

The irony that you've posted this dated 30th June...

Posting some sample code or something might help, and in a specific language
group.

But it sounds like you need some kind of validation function like
(psuedocode, and I'm a C++ programmer so forgive any oddities [oh , and I've
been awake for 36 hours so forgive any glaring errors :-) ] )

Boolean AllowBooking( DateTime dateTime )
{
// Check that the hour is before 11 or the booking date isn't tomorrow.
Some adjustment needed to prevent booking for today.
return ( TodaysDate.Time.Hour < 11 || ( todaysDate.Date.Day + 1 !=
dateTime.Date.Day ) );
}

HTH,

Steve
 
well june 30 th was due to me playing my server date time which i posted
from...



Steve McLellan said:
The irony that you've posted this dated 30th June...

Posting some sample code or something might help, and in a specific language
group.

But it sounds like you need some kind of validation function like
(psuedocode, and I'm a C++ programmer so forgive any oddities [oh , and I've
been awake for 36 hours so forgive any glaring errors :-) ] )

Boolean AllowBooking( DateTime dateTime )
{
// Check that the hour is before 11 or the booking date isn't tomorrow.
Some adjustment needed to prevent booking for today.
return ( TodaysDate.Time.Hour < 11 || ( todaysDate.Date.Day + 1 !=
dateTime.Date.Day ) );
}

HTH,

Steve

bredal Jensen said:
Hello gurus,


I'm building a small booking system and i have come accross quiet a tedious
pitfall.

"I need to make sure that people do not book for tomorrow when todays time
is greater or equal to 11."


Well some of you probably allready know the answer but this is not so
obvious for me.

Can anyone solve this puzzle for me?

The booking hour is of no importance. Only the hour at which we are making
this booking
and only if it is the day after today.


Many thanks in advance

J.B
 
private static bool CheckReservationDate(DateTime ReservationDate) {
bool ret = false;
DateTime Current = DateTime.Now ;
if(Current.Hour >= 11) {
DateTime NowDateOnly = new DateTime(Current.Year, Current.Month,
Current.Day) ; //remove time
DateTime ReservationDateOnly = new
DateTime(ReservationDate.Year,ReservationDate.Month,ReservationDate.Day);
//remove time
TimeSpan t = ReservationDateOnly.Subtract(NowDateOnly) ;
ret = t.Days > 1; //any date after tomorrow is fine.
}
return ret;
}
 
Hello gurus,


I'm building a small booking system and i have come accross quiet a tedious
pitfall.

"I need to make sure that people do not book for tomorrow when todays time
is greater or equal to 11."


Well some of you probably allready know the answer but this is not so
obvious for me.

Can anyone solve this puzzle for me?

The booking hour is of no importance. Only the hour at which we are making
this booking
and only if it is the day after today.


Many thanks in advance

J.B
 
Back
Top