1. SEP 2017: upgrading weekday()
Contents
1.1. Abstract
weekday() is prone to the bug #15200, and suffers from numerous limitations. For instance, its help page claims to accept dates as text like "17-Feb-2031", while it is not actually the case. We propose to fix the bug and extend weekday to accept new input syntaxes. A new LANG option is also introduced.
1.2. New dates syntaxes
All new syntaxes will accept the 'long' option.
1.2.1. weekday()
Without specifying any date number, the current date of today will be considered.
1.2.2. weekday(dateStrings)
dateStrings is a matrix of strings providing the dates. Four string formats are accepted and described here-below. In the matrix, all strings must have the same format:
DD-Mmm-YYYY like "12-Feb-2031" or "7-Jun-2024". Remarks:
Day numbers < 10 may be specified without leading 0.
The short month name is mandatory in english
DD/MM/YYYY like "23/7/2018". Remark: DD or/and MM < 10 may or not have a leading zero.
YYYY-MM-DD like "2018-07-23". Remark: DD or/and MM < 10 must have a leading zero.
YYYY-MM-DD HH:MN:SS.sss like "2018-07-23 17:48:37.1". Remarks: DD or/and MM < 10 must have a leading zero. All what follows the first space is ignored.
1.2.3. weekday(Y, M, D)
Y, M, and D are three element-wise matrices of numbers having the same sizes. Y are the year numbers. M are the month indices in the year, from 1 to 12. D are the day indices in the month, from 1 to 31. The input date #i is defined with D(i)/M(i)/Y(i).
1.2.4. weekday(YMD)
YMD is a Nx3 matrix of numbers. The first column YMD(:,1) are years. The second column YMD(:,2) are month indices. YMD(:,3) are day indices. The YMD #ith row defines the #ith date YMD(i,3)/YMD(i,2)/YMD(i,1). This kind of input will be easily distinguished from a Nx3 matrix of datenums by testing the range of values in columns.
1.3. New LANG option
Currently, weekday always returns the short or long month names in the current session language, that may be distinct from en_US. From here, getting month names in en_US or any other supported language than the current one is complicated or even impossible, since gettext() is currently unable to translate an input other than from en_US. We propose to introduce a new LANG option to be specified at any place (before or after "long") 'after' the dates input(s). When it is used, month names are returned in the required language instead of in the session's language. LANG value is a single text word in the standard cc_CC format.
Despite this would not be back-compatible, we could propose making en_US the default instead of the current locale up to now.
1.4. Authors
2017 - Samuel GOUGEON