Again,
Envsub (and the equivalent syntax
Var -= Value [, TimeUnits]) just subtracts a number from another one,
by default. That's it.
To get the
special behaviour that it treats certain numbers as timestamps, you need to add the optional
TimeUnits parameter. It's documented.
And no, it doesn't check if an integer could potentially be a timestamp - what about numbers that look accidently like a timestamp ? (See eg
example #3, especially because a
valid timestamp doesn't need to contain the smaller units like secs, mins, ... per the docs, they'll get filled with default values)
Such guessing could really lead to unexpected behaviour. See the difference ?
Code: Select all
var1 := 2005 ; https://www.autohotkey.com/docs/commands/FileSetTime.htm#YYYYMMDD
var2 := 2003
var1 -= var2, days ; EnvSub, var1, var2, days
MsgBox, %var1% ; 731 (days)
var1 := 2005
var2 := 2003
var1 -= var2 ; EnvSub, var1, var2
MsgBox, %var1% ; 2
If you see
EnvSub, Var, Value or the equivalent
Var -= Value in a script, there is no clear indication that it would do what you expect, and the docs do not say it either.
(Of course, a command name like
FormatTime could indicate that the command handles timestamps - but contrary to its title, this topic doesn't seem to be about that command.)