Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2018-04-16
16:40 • Ticket [73384a82ad] clock scan calendaric calculation error status still Ope... artifact: 797d53588a user: sebres
15:57 • New ticket [73384a82ad]. artifact: 33bf1edd5c user: anonymous

clock scan calendaric calculation error

Open73384a82adedf4a7986301cfad8ae27017f68ec0Created 9 years agoUpdated 9 years ago
Descriptionplain2018-04-16 15:57:59
foreach part {yesterday today now tomorrow} {
    puts stdout "[clock format [clock scan "${part} 3 months ago" ] -format {%Y.%m.%d}] : ${part} 3 months ago"
}

2018.01.17 : yesterday 3 months ago    !!! FALSE that's tommorrow 3 months ago
2018.01.16 : today 3 months ago
2018.01.16 : now 3 months ago
2018.01.15 : tomorrow 3 months ago     !!! FALSE that's yesterday 3 months ago

Could it be yesterday and tomorrow are mixed in calendar calculations?
Unsing '-3 months' instead of '3 months ago' gives correct results!

foreach part {yesterday today now tomorrow} {
    puts stdout "[clock format [clock scan "${part} -3 months"] -format {%Y.%m.%d}] : ${part} -3 months"
}

2018.01.15 : yesterday -3 months
2018.01.16 : today 3 months
2018.01.16 : now 3 months
2018.01.17 : tomorrow -3 months
sebresplain2018-04-16 16:40:44
The problem is - both "yesterday/tomorrow" as well as "3 months" are currently relative units (effectively days).
So the suffix "ago" works like simply "negation" for both units equally.

So unfortunately ATM it is even equally to:
  "tomorrow 3 months ago"  ===  "1 day 1 month ago" 
  "yesterday 3 months ago" === "-1 day 1 month ago"

Sounds a bit strange, but simply said: don't use "ago" suffix if you've multiple relative units (as mix) in the free-scan string.

@Kevin, @TCT Theoretically I could relative easy change the logic of "tomorrow/yesterday" (should not be tDAY_UNIT (yyRelDay) anymore, so can affect the base instead of relunit), but such change is not backwards-compatible at all.

What would you say about?
Log in (anonymous is fine) to add a comment.