I may be misunderstanding TimeDiff

Started by 1bosborn, February 24, 2021, 12:46:57 PM

Previous topic - Next topic

1bosborn

I'm trying to determine if a file is over 10 minutes old using TimeDiff:
timenow = YmdHms()
filetime = FileTimeYmdHms(filename)
fileage = TimeDiff(timenow,filetime)
If fileage < 0000:00:00:00:10:00
do stuff
EndIf
The If statement evaluates true even if the file is older. I added a message statement for troubleshooting and it said fileage was 0000:00:00:00:12:17 yet Debug said "If do true" and the script did the stuff it should have if the file were less that 10 minutes old.
Thoughts or advice?
Thanks as always.

JTaylor

Put quotes around the value and see if that helps.

Jim

1bosborn

Well now I just feel silly. That worked like a charm, thanks.

td

It is a bit confusing. The colon is the concatenation operator so 0000:00:00:00:10:00 reads as a bunch of numbers that are concatenated to each other with the result being the string "00001000".  The reason some of the leading zeros are dropped is that the integer 0000 or 00 are both read as the integer 0 before being converted to a string. The extra zeros have no significance in integer constants.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade