Suggestion for @DATE[] input

May 29, 2008
571
4
Groton, CT
With the introduction of the new ISO-format dates formats 5 and 6, @DATE[], @DATECONV[], @MAKEAGE[], and other functions will accept a date specified with only two parts as if it were format 6.

ISO dates properly have 4-digit years, but TCC functions accept both 2- and 1-digit years.

The problem is, as I see it, that when a user manually enters a date with only two components, they are much more likely to mean month/date within the current year or date.month within the current year than some date in January in a low-numbered 21st century year. It is likely that a user who enters 04/07 means either April 7 or July 4 this year, and not Jan 7, 2004. Dates read from files, however, are likely to have the full 4-digit year and 3-digit day within the year.

So .BTM files processing file input would have no problem, but .BTM files handling user manual input may get incorrect dates.

I suggest that for recognition of a format 6 date where the input format is not explicitly stated, the year be required to be 4 digits. A 2-element date without a 'W' like 04-07 could be rejected as invalid format or interpreted as either day-month or month-day according to the default format. In older versions of TCC, a 2-element date was always rejected.

By way of example, my suggested is that @DATE[4-7,6] would be accepted as 2004-007 (and @DATE[2004-007] would be accepted as format 6), but @DATE[4-7] (without the ,6) would be either rejected or accepted as 04-07-%_year and interpreted as the default format (for formats 1 and 2) and for format 3 systems, it would be interpreted as %_year-04-07. Of course, not only @DATE, but also @DOW and all the other functions that take a date as input.

(Dates with a 'W', properly should have 4-digit years, but the 'W' truly does
make the intent unambiguous.)
 
May 20, 2008
3,515
4
Elkridge, MD, USA
dcantor wrote:
| With the introduction of the new ISO-format dates formats 5 and 6,
| @DATE[], @DATECONV[], @MAKEAGE[], and other functions will accept
| a date specified with only two parts as if it were format 6.
...
|
| I suggest that for recognition of a format 6 date where the input
| format is not explicitly stated, the year be required to be 4
| digits. A 2-element date without a 'W' like 04-07 could be rejected
| as invalid format or interpreted as either day-month or month-day
| according to the default format. In older versions of TCC, a
| 2-element date was always rejected.
...
| (Dates with a 'W', properly should have 4-digit years, but the 'W'
| truly does make the intent unambiguous.)

That would really be a DWIM function! Actually, I would much rather see a
new function, loosely modelled on @GETFOLDER[]:
@GETDATE[order or format, default value]
which would allow the ORDER to be specified explicitly using any one to all
three of the letters YMD, (or any one or two of them, or one of the format
codes 0..6. Any date field the interactive user skipped using the Esc or Tab
key would use the respective fields from the default value. The function
would display a dialog explicilty specifying what is expected in each field
(using the current language of TCC) and the default values. This function
would never be ambiguous, nor would it require guessing, and would eliminate
the need for TCC users to write any code to parse dates. The function ought
to validate that the entry is a valid date, too.
Naturally, a companion function @GETTIME ought to exist as well, with
analogous semantics.
--
Steve
 
May 29, 2008
571
4
Groton, CT
dcantor wrote:
| With the introduction of the new ISO-format dates formats 5 and 6,
| @DATE[], @DATECONV[], @MAKEAGE[], and other functions will accept
| a date specified with only two parts as if it were format 6.
...
|
| I suggest that for recognition of a format 6 date where the input
| format is not explicitly stated, the year be required to be 4
| digits. A 2-element date without a 'W' like 04-07 could be rejected
| as invalid format or interpreted as either day-month or month-day
| according to the default format. In older versions of TCC, a
| 2-element date was always rejected.
...
| (Dates with a 'W', properly should have 4-digit years, but the 'W'
| truly does make the intent unambiguous.)

That would really be a DWIM function! Actually, I would much rather see a
new function, loosely modelled on @GETFOLDER[]:
@GETDATE[order or format, default value]
which would allow the ORDER to be specified explicitly using any one to all
three of the letters YMD, (or any one or two of them, or one of the format
codes 0..6. Any date field the interactive user skipped using the Esc or Tab
key would use the respective fields from the default value. The function
would display a dialog explicilty specifying what is expected in each field
(using the current language of TCC) and the default values. This function
would never be ambiguous, nor would it require guessing, and would eliminate
the need for TCC users to write any code to parse dates. The function ought
to validate that the entry is a valid date, too.
Naturally, a companion function @GETTIME ought to exist as well, with
analogous semantics.
--
Steve


I'm not trying to propose a DWIM function; what I'm saying is that when the user enters a 2-element date, it probably won't result in what the user wants. Because of that, it's likely to be a DSOTWIM (Does Something Other Than What I Mean).

It can be solved by requiring the 4-digit year for an ISO yyyy-ddd date. Trying to interpret it as something else is secondary; an invalid date error is an acceptable result.

Maybe all we need is an @ISDATE function to test whether a string is a valid date without throwing an error.

Echo %@ISDATE[4-7]
0
Echo %@ISDATE[2004-007]
1
 
Similar threads
Thread starter Title Forum Replies Date
C Question / Suggestion Support 1
fpefpe Suggestion for next release Support 2
C textsort suggestion for tpipe Support 8
C New suggestion Support 1
S Forum suggestion Support 0
rconn Suggestion list for next major version Support 0
J Suggestion for next version Support 0
S Enhancement suggestion: @format and @formatn Support 0
S Suggestion: enhanced automatic quoting of filenames Support 2
S HELP nit and suggestion Support 2
dcantor Take Command V10 @WINPID suggestion. Support 2
dcantor Syntax files, and suggestion Support 0
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
mfarah Fixed The DATE command produces the wrong error message. Support 1
T Date format date different from cmd Support 7
Jesse Heines How to? How to display picture creation date with dir command Support 6
Jesse Heines "Taken" date for JPG and PNG files Support 4
Joe Caverly DATE format 4 Support 7
fpefpe touch - date format Support 2
C 7zip with date range .vs. filelist created with dir and daterange Support 0
C How to? Add date/time to custom tpipe based BTM Support 1
vefatica Download center not up to date Support 4
Joe Caverly How to? Date Range in command line for 7zip /= Support 1
N date and cmd compatibility Support 10
rps Functions @year[date] @isowyear[date] help Support 7
S Closing date for V16 suggestions Support 1
JohnQSmith DATE /T Support 13
A How to? Create a date range based upon creation date Support 2
S How to? Command dialogs vs. size/date/etc. exclusion ranges Support 1
M How to? Effectively "combine" date and time ranges... Support 2
CWBillow Make a folder named Date-Time Support 18
vefatica Do UNTIL DATETIME date time Support 6
S Date range question Support 4
Roedy date range documentation error Support 2
Jay Sage Inconsistency in Date Formats Between @DATE and @MAKEDATE Support 3
dcantor More date-related help items for V11 Support 0
dcantor Help text for Date Formats Support 0
dcantor @DATE help example Support 0
CWBillow Date and Time in names Support 11
S INPUT fails if the entered text contains pair of square brackets Support 6
Joe Caverly Command Input Syntax Colouring Support 3
T Disable audible beep on input and inkey Support 2
T input accepts empty answer Support 5
WinLanEm INPUT problem Support 1
rps Command Input Window tab completion broken Support 7
D Documentation Using "send all input to other tabs" Support 11
J Input text converts to uppercase Support 1
B Select and run lines from Command Input panel? Support 1
Charles Dye TYPE /P behaves strangely with piped/redirected input Support 0
T command input font Support 2

Similar threads