Yyyy Mm Dd

A precise pattern describing a DateStamp which folks often can quickly grok without language barriers. It also sorts the same as a number or string and as a date type in most RDBMS (if zero-padded). Variations include a space or a dash between elements.

Now available in an international standard near you: http://en.wikipedia.org/wiki/ISO_8601

I wish I could remember the Pattern template off the top of my head, but I wanted to get this posted -- ChrisGarrod

Yyyy
the year CE as a signed integer, ones in this decade have RegularExpression 201[0-9] -- This format is yNk compliant until y10k, if we want y10k compliance, allow any number of digits in this position.
Mm
month, using leading zero for most of them. RegularExpression: 0[1-9]|1[0-2]
Dd
day of month, always with two digits, if we ignore leap years and the ThirtyDays litany, the RegularExpression is: [0-2][1-9]|[123]0|31 LeapYear? will require a more specialized object.

If you want a PointInTime, just add .HhMmSs to the date.

JuliusCaesar ignored the warning: Beware TheIdesOfMarch, and was assassinated on -430315. Perhaps it was after 10am and before 8pm: -430315.1

My personal favorite expression of date is a compressed text string with the three letter abbreviation of the month as the middle portion: 2011Apr25. Only one more character, and kinda hard to "misunderestimate" that one, eh?

A different Anon replies, for my own use I've started using 2011_04Apr_25; this way the computer has the number for the month for easier sorting and the human (me) gets the 3 letter text for quicker comprehension. Also, The way the breakdown is described, the titled version should be YYYYMMDD (uppercase = required, lowercase = ignore if zero).

Also with [0-2][1-9]|[123]0|31 LeapYear? works fine, xxxx0229 is allowed just like xxxx0431. A more specialized construct is needed if you don't want to ignore the ThirtyDays litany, or block LeapDay? on non leap years. And feel free to DeleteIfCooked? my regex comment when it doesn't say the opposite of what it means.


EditText of this page (last edited April 29, 2013) or FindPage with title or text search