Date() Question

Everything else that doesn't fall into one of the other PB categories.
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Date() Question

Post 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?
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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 :)
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post 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
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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 :)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Date() Question

Post 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.
Post Reply