User Tools

Site Tools


ttrack:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
ttrack:start [2012/12/11 12:09]
andy
ttrack:start [2012/12/11 12:16] (current)
andy [Time/Date Parsing]
Line 22: Line 22:
  
 Note the inconsistency where "​this"​ becomes synonymous with "​next"​ for the current day --- this reflects the fact that I don't believe someone would ever say "this Wednesday"​ if they meant "​today"​. Note the inconsistency where "​this"​ becomes synonymous with "​next"​ for the current day --- this reflects the fact that I don't believe someone would ever say "this Wednesday"​ if they meant "​today"​.
 +
 +The algorithms for each version are thus (assuming ''<​weekday>''​ and ''<​current weekday>''​ have been converted to zero-based integers where Monday is zero):
 +
 +  * **''"​last <​weekday>"''​**
 +    * ''<​new date> = <old date> - <current weekday> - 7 + <​weekday>''​
 +  * **''"​this <​weekday>"''​**
 +    * ''​if <​weekday>​ == <current weekday>:''​
 +      * ''<​new date> = <old date> + 7''​
 +    * ''​else:''​
 +      * ''<​new date> = <old date> - <current weekday> + <​weekday>''​
 +  * **''"​next <​weekday>"''​**
 +    * ''<​new date> = <old date> - <current weekday> + 7 + <​weekday>''​
  
 A bare day of the week (e.g. just "​Tuesday"​) is always taken as the day of the //current// week (Monday-based),​ as opposed to some date parsing packages which regard this as synonymous with "next Tuesday"​. This means it doesn'​t quite correspond exactly with any of the last/​this/​next interpretations,​ but that's probably OK. A bare day of the week (e.g. just "​Tuesday"​) is always taken as the day of the //current// week (Monday-based),​ as opposed to some date parsing packages which regard this as synonymous with "next Tuesday"​. This means it doesn'​t quite correspond exactly with any of the last/​this/​next interpretations,​ but that's probably OK.
ttrack/start.1355227742.txt.gz ยท Last modified: 2012/12/11 12:09 by andy