Welcome to comp.lang.c!

R

Richard Bos

Buck Rogers said:
Civilised people write dates in the form dd-mm-yy, and use decimal
currency.

YM either yyyy-mm-dd (nice for sorting) or dd-mm-yyyy; we don't want
another century bug. And I'm not sure there is a country any more which
doesn't use decimal currency; the UK got rid of shillings three (?)
decades ago. Which, on-topically, makes coding money rather easier,
because you only need a single floating- or fixed-point number.

Richard
 
D

Dan Pop

In said:
Civilised people write dates in the form dd-mm-yy,

No, civilised people write dates in the form yyyy-mm-dd, so that at
least using '-' instead of '/' is a hint at which is which[1].[/QUOTE]

Civilised people write dates in a context dependent format. When the
document is supposed to be read by other people from the same locale,
the locale conventions are used, whether they're sensible or not. In most
European countries this means dd.mm.yy[yy] and this is also the format
imposed when filling forms in these countries.

When the document is supposed to be read by people belonging to other
locales, the best solution is to use the three letter abbreviation of the
month and all the digits of the year: 13-JAN-2004 simply cannot be
misinterpreted, regardless of the locale conventions of the reader.

The yyyy-mm-dd format (with or without separators) is particularly useful
in file names, for sorting purposes: a string sorting (or numeric sorting
if no separators are used) will also be calendrically correct.

Dan
 
R

Randy Howard

When the document is supposed to be read by people belonging to other
locales, the best solution is to use the three letter abbreviation of the
month and all the digits of the year: 13-JAN-2004 simply cannot be
misinterpreted, regardless of the locale conventions of the reader.

Sure it can, if the reader has no idea what "JAN" means. Not all languages
(or even most of them) use a word starting with "JAN" for January.

I suppose that 13-ENE-2004 would could not possibly be misinterpreted by
a reader, regardless of locale conventions?

As such, I think the YYYY-MM-DD format is still the better method, especially
since dates actually sort correctly when it is used.
 
J

John L

Randy Howard said:
Sure it can, if the reader has no idea what "JAN" means. Not all languages
(or even most of them) use a word starting with "JAN" for January.

I suppose that 13-ENE-2004 would could not possibly be misinterpreted by
a reader, regardless of locale conventions?

Indeed. A decade or so ago I had to debug a program processing
a French news feed. After several months it had suddenly stopped
working. It turned out that "AUG" is not the usual French
abbreviation for August and so stories were being rejected.

John.
 
D

Dan Pop

In said:
Sure it can, if the reader has no idea what "JAN" means. Not all languages
(or even most of them) use a word starting with "JAN" for January.

If the document is written in English, the reader is supposed to be
familiar with the English language. If I write the document in another
language, I would use the common month abbreviations of that language.
I suppose that 13-ENE-2004 would could not possibly be misinterpreted by
a reader, regardless of locale conventions?

You're either deliberately obtuse or completely missing the point.
As such, I think the YYYY-MM-DD format is still the better method, especially
since dates actually sort correctly when it is used.

Nope. The meaning of 2004-11-01 is still far from obvious to someone who
is not familiar with the convention (YYYY-MM-DD is a convention just like
any other and relatively few people are intimately familiar with the ISO
standards). The only reliable way of disambiguating between month and
day is by using the abbreviation of the month name of the language in
which you're writing.

Dan
 
J

James Hu

Nope. The meaning of 2004-11-01 is still far from obvious to someone who
is not familiar with the convention (YYYY-MM-DD is a convention just like
any other and relatively few people are intimately familiar with the ISO
standards). The only reliable way of disambiguating between month and
day is by using the abbreviation of the month name of the language in
which you're writing.

Well, not the only way. You could use the name of the month spelled
out in full. :)

And in a (vain?) attempt to bring this back on topic, you would use
"%Y-%b-%d" as the format specifier to strftime() to get the abbreviated
form, and "%Y-%B-%d" to get the full month name form.

-- James
 
C

CBFalconer

James said:
(e-mail address removed) (Dan Pop) wrote

Well, not the only way. You could use the name of the month
spelled out in full. :)

And in a (vain?) attempt to bring this back on topic, you would
use "%Y-%b-%d" as the format specifier to strftime() to get the
abbreviated form, and "%Y-%B-%d" to get the full month name form.

But there seems to be no way to get ISO format from strftime().
 
J

Joe Wright

CBFalconer said:
But there seems to be no way to get ISO format from strftime().
I didn't see a smiley. What about "%Y-%m-%d"? Prints "2004-01-14"
tonight.

#include <stdio.h>
#include <time.h>

int main(void) {
char iso[11];
struct tm tm;
time_t tim;
time(&tim);
tm = *localtime(&tim);
strftime(iso, sizeof iso, "%Y-%m-%d", &tm);
puts(iso);
return 0;
}

Did I miss something again?
 
C

CBFalconer

Joe said:
I didn't see a smiley. What about "%Y-%m-%d"? Prints "2004-01-14"
tonight.

Because I totally missed the %m specifier. Notice I said seems,
implying my inherent doubt about my own conclusions :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,177
Latest member
OrderGlucea
Top