TIP 444: Add "weekdays" unit in clock add

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Pietro Cerutti <gahr@gahr.ch>
State:          Final
Type:           Project
Vote:           Done
Created:        23-Feb-2016
Post-History:   
Tcl-Version:    8.7

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 http://core.tcl.tk/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.

History