Page 1 of 1

Date() Question

Posted: Thu May 08, 2003 5:14 pm
by ebs
The help file says:

Code: Select all

Debug Hour(Date(0, 0, 0, 11, 3, 45))  ; Outputs '11'.
but it doesn't! It outputs '0'.

Is it possible to use dates where only the time portion (hms) are set?

Posted: Thu May 08, 2003 6:29 pm
by Pupil
It's an error either in the manual or in the library, if you supply the day, month and year 1/1/1970 it should work ok :)

Posted: Thu May 08, 2003 6:34 pm
by ebs
Pupil,

Yeah, I came to the same conclusion, so I wrote this wrapper function:

Code: Select all

Procedure.l Time(Hour.l, Minute.l, Second.l)
  ProcedureReturn Date(1970, 1, 1, Hour, Minute, Second)
EndProcedure
I hope Fred makes it work with zeros in the date portion, though.

Regards,
Eric

Posted: Thu May 08, 2003 6:42 pm
by Pupil
Actually if you just want to create a date value from hour, minute, seconds you might as well do this:

Code: Select all

time.l = Hours*3600 + Minutes*60 + Seconds
Probably what PB does internally :)

Re: Date() Question

Posted: Fri May 09, 2003 6:50 am
by PB
> Debug Hour(Date(0, 0, 0, 11, 3, 45)) ; Outputs '11'.
> but it doesn't! It outputs '0'.

The docs are wrong. This isn't a bug (and I know you didn't say it was),
because you didn't supply any valid date (no month is 0, etc). The docs
should be changed to avoid this misunderstanding in future.