TIP 444: Add "weekdays" unit in clock add

Login
Author:         Pietro Cerutti <[email protected]>
State:          Final
Type:           Project
Vote:           Done
Created:        23-Feb-2016
Post-History:   
Tcl-Version:    8.7
Tcl-Branch:     tip-444

Abstract

This TIP proposes an enhancement to the clock add command to support performing days arithmetic using weekdays only.

Rationale

The clock add command allows to perform time arithmetic using a variety of time units, including days. However, it offers no easy way to skip weekends. It is often desired to perform weekdays arithmetic that involves adding or subtracting a number of non-weekend days to a certain date. This is useful in example when computing delivery dates.

Proposal

The weekdays time-unit is added to the list accepted by the clock add command. The count argument represents weekdays (Mon-Fri) to be added (or subtracted in case of a negative value) to the date. The result of adding weekdays to a date is never a weekend day, unless the starting day is itself a weekend day and count is 0.

Reference Implementation

Available at https://core.tcl-lang.org/tcl/timeline?t=tip-444

Discussion

A point has been raised as to whether weekday is unambiguous enough. For instance, in Sweden there seems to be some disagreement on whether the translation vardag includes Saturdays. As an alternative, the term workday has been mentioned. This, however, has the downside of introducing the concept of working days vs. public holiday. Also, the working week is not Mon-Fri in all countries, see https://en.wikipedia.org/wiki/Workweek_and_weekend#Around_the_world .

TIP does not try to accomodate locale-specific features and characteristics. For this reason, it seems best to stick to weekday as the name of the unit and specifically mention that (Mon-Fri) is intended in the documentation.

Copyright

This document has been placed in the public domain.