Hi!

I've prepared a nant patch that adds support for datetime and timespan
literals in expressions.

This is a first step towards improving implicit vs explicit conversions
issue. Today, the only way to specify a date literal is to use:
convert::to-datetime("MM/DD/YYYY") which is not very elegant.

I propose a patch that adds:

- datetime literals (enclosed in square brackets)

[YYYY-MM-DD]
[YYYY-MM-DD HH:MI]
[YYYY-MM-DD HH:MI:SS]
[YYYY-MM-DD HH:MI:SS.MIL]

- timestamp literals (enclosed in square brackets, too)

[HH:MI:SS.MIL]
[HH:MI:SS]
[DD:HH:MI:SS.MIL]
[DD:HH:MI:SS]

Additionally it changes SafeConvert to manually produce the
datetime/timestamp according to the mentioned format. This is used in
PropertyDictionary.Expand*() to ensure that all datetime strings are
produced in YYYY-MM-DD [HH:MI:SS[.MIL]] format.

Now, instead of:

convert::to-datetime('01-01-2000') + convert::to-timespan('01:01:01')

you can write:

[2000-01-01] + [01:01:01]

which is definitely more readable and typesafe.

What do you think? May I commit it?

Jarek

Attachment: dateliterals.patch
Description: Binary data

Reply via email to