FormatTime considers 60 seconds as valid input

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
vaypay
Posts: 4
Joined: 02 Aug 2016, 02:29

FormatTime considers 60 seconds as valid input

04 Jan 2024, 05:29

The FormatTime function considers an input of 60 seconds as valid. The following V2 code demonstrates this:

Code: Select all

msgbox 	(FormatTime(20000101000059, "yyyy/MM/dd HH:mm:ss") "`n" FormatTime(20000101000060, "yyyy/MM/dd HH:mm:ss") "`n" FormatTime(20000101000061, "yyyy/MM/dd HH:mm:ss") "`n"
		FormatTime(20000101005900, "yyyy/MM/dd HH:mm:ss") "`n" FormatTime(20000101006000, "yyyy/MM/dd HH:mm:ss") "`n"
		FormatTime(20000101230000, "yyyy/MM/dd HH:mm:ss") "`n" FormatTime(20000101240000, "yyyy/MM/dd HH:mm:ss"))

/* Returns:
2000/01/01 00:00:59
2000/01/01 00:00:60
2000/01/01
2000/01/01 00:59:00
2000/01/01
2000/01/01 23:00:00
2000/01/01
*/
60 minutes and 24 hours inputs are not valid as they should be, though.
The same happens in V1.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: FormatTime considers 60 seconds as valid input

04 Jan 2024, 07:40

This is not a bug. Moving this thread from “Bug Reports” to “Ask for Help (v2)”.

vaypay wrote: The FormatTime function considers an input of 60 seconds as valid.
Just because it displays the seconds doesn’t mean it considers it valid. When you provide invalid inputs, the output is undocumented.

vaypay wrote: 60 minutes and 24 hours inputs are not valid as they should be, though.
Why should they be valid? Nowhere does it say they should be. If your conclusion is that they should be valid because of the output it gives when providing invalid seconds as input, that is not a logical conclusion.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: billyt, bobstoner289 and 66 guests