TEXT   23

Date fornats

Guest on 11th June 2022 01:49:35 AM

  1. Sensible Date Format
  2. Why do I use a strange-looking date format like
  3.  
  4. 96.Feb.29
  5. or (when more details needed)
  6. 1996.Feb.29 (Thu) 16:45:23.7
  7. ? This format is actually quite consistent: the units of time start from large units (years), and decrease as you read to the right -- which is already how “Feb. 29” and “16:45” work. To complete the picture, the amount of prefix and suffix you include simply depends on the amount of context and precision (resp.) you need:
  8. When mentioning the year would be redundant, you omit “2002”. Or, if just the century is being assumed, you leave off “20” and just use “02.Feb...”, and if the year is obvious that leaves us with “Feb...”.
  9. At the end, omit the units too small to be relevent: The seconds are usually left off time-of-day when irrelevent, just as the hour:minute is omitted when only the date matters.
  10. Comparing to other alternatives
  11. The european date format -- which reverses the order of the day/month/year -- is justifiable, since it allows the reader's eye to quickly pick out the day-of-month (which is what people are probably most interested in) while still specifying the month and year. The American date format of “month/day/year, hour:minute:second am|pm”, tries to mimic speech patterns (which is a slightly different mode of thought), but in practice this just ends up hopelessly muddling everything.
  12. Spelling the day-of-week
  13. Regardless of the particular format you choose, I've found that taking the extra half-second to write the month as a three-letter abbreviation, rather than the number, practically always makes my message clearer. Compare “1996.10.17” with “1996.Oct.17”, or “11-9-2001” with “11-Sep-2001”. Smart software will be able to parse the full form, no problem.
  14. Some possible exceptions:
  15.  
  16. The one time I don't do this is when making filenames which include a date (e.g. a series of backup files): crossword20041201.txt instead of crossword2004Dec01.txt. The computer has no way of knowing that filename happens to include an encoded date, so I use raw numbers to keep the file-listings alphabetically. (Note that if the file's timestamp won't change, then you don't actually need to incorporate the date into the filename, and you can display the files by date -- e.g. ls -lt, in *nix.)
  17. When the document is going to be translated between languages, using letters for the month may need to be translated as well, whereas numbers can be left alone. Though again, cultural differences about the year-month-day ordering is still a danger point: If the month-abbreviation isn't emphasizing the date format, an translator -- possibly

Raw Paste


Login or Register to edit or fork this paste. It's free.