[an error occurred while processing this directive] [an error occurred while processing this directive]
Why do I use a strange-looking date format like
96.Feb.29or (when more details needed)
1996.Feb.29 (Thu) 16:45:23.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:
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.
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.
Some possible exceptions:
Many programming environments follow POSIX's strftime format. The format string I like best is
%Y.%b.%d (%a), %H:%M:%Sfor Year.month.day (weekday), hour:min:sec. To include a time-zone append %Z to this format string; for a 2-digit year use %y instead of %Y.
<!--#config timefmt="%Y.%b.%d (%a), %H:%M %Z" --> <!-- The above format will print times as, eg, "2001.Feb.31 (Sat) 04:56 CST". --> <!--#echo var="DATE_LOCAL" --> is the current time; <br /> <!--#echo var="LAST_MODIFIED" --> is when this page was last modified.
2013.May.24 (Fri) 06:55 EDT is the current time;
2012.Jan.21 (Sat) 14:23 EST is when this page was last modified.
use POSIX; $nattyDateFormat = "%Y.%b.%d (%a), %H:%M:%S"; print POSIX::strftime( $nattyDateFormat, localtime());
text(a bit like
printf) to create formatted strings:
(require (lib "19.ss" "srfi")) ; Srfi 19 is standard, but `require' is PLT-scheme specific. (define natty-date-format "~Y.~b.~d (~a), ~H:~M:~S") (date->string (current-date) natty-date-format) ⇒ "2004.Sep.21 (Tue), 13:33:57" (date->string (string->date "1999.Jun.21 (Mon), 23:45:56" natty-date-format) natty-date-format) ⇒ "1999.Jun.21 (Mon), 23:45:56"
alias date 'date +"%Y.%b.%d (%a), %H:%M:%S"' set prompt = "%Y.%w.%D (%d) %T %# "(Note that for prompt, we have to use substitutes for %H and %b.)
<key>AppleICUDateFormatStrings</key> <dict> <key>1</key> <string>yy'.'MMM'.'dd</string> <key>2</key> <string>yyyy'.'MMM'.'dd</string> <key>3</key> <string>yyyy'.'MMM'.'dd</string> <key>4</key> <string>yyyy'.'MMM'.'dd' ('EEE')'</string> </dict> <key>AppleICUTimeFormatStrings</key> <dict> <key>1</key> <string>HH':'mm</string> <key>2</key> <string>MMM'.'dd' ('EEE'), 'HH':'mm':'ss</string> <key>3</key> <string>MMM'.'dd' ('EEE'), 'HH':'mm':'ss</string> <key>4</key> <string>HH':'mm':'ss z</string> </dict>
Feel free to send me other directions -- e.g. for linux's bash, for Windows, etc.
"The deadline is midnight Wednesday".Does this mean Wednesday 0:00 (coming just after Tuesday 23:59), or is it Wednesday evening (technically, Thursday 0:00am, and no longer really Wednesday)?
By the way, if you want to make it clear you're using a 24-hour clock, it's not always enough to use a leading zero (e.g. 08:30), since times in the range [11:00,13:00) are still ambiguous. You can consider using `h' as a divider rather than `:', to get 8h30, 11h30, 13h00.
Here is another call for a sensible date format.
While overall it makes many good points, it does suffer from one incorrect argument, saying that we humans should use dates which are easy for computers to read and compare and sort. That's backwards -- we should not change our mode of thought just to make our tools easier to use; good tools are made to work for us. Elementary software practice means having a library function which to parse whatever (unambiguous) date format humans use; the programmer calls that library function as needed, rather than always rewriting code for this task. ...But otherwise, the arguments about reducing human confusion are right on the money![an error occurred while processing this directive]