Dates & things in C

Norman Diamond diamond at diamond.csl.sony.junet
Mon Jun 5 13:53:59 AEST 1989


In article <1604 at optilink.UUCP> cramer at optilink.UUCP (Clayton Cramer) writes:

>It's a shame that more Americans aren't sensitive to the inter-
>national differences.  For example, the user interface software
>I'm writing will be compiled for several different countries, and
>it's really only a little more work to say:
>
>    #ifdef AMERICA
>        sprintf(Buffer, "%s-%02d-%02d", MonthStr, Date, Year);
>    #else /* BENIGHTEDPARTSOFWORLD */
>        sprintf(Buffer, "%02d-%s-%02d", Date, MonthStr, Year);
>    #endif
>
>See?  Just be sensitive. :-)

There are a lot of #else-#if's.  For example, in Japan,

    sprintf(Buffer, "%02d.%02d.%02d", Year, Month, Date);

but really more like

    sprintf(Buffer, "%c02d$BG/(J%02d$B7n(J%02d$BF|(J", Era, Year, Month, Date);

... my apologies to those of you who can't see the characters for
"year", "month", and "day" in the above character string 'cause you're
using fascist terminals which aren't sensitive to international
character sets...

We really need a preprocessor #switch for this.

In practice, execution-time if's are more common, and they should be
but aren't execution-time switch's.

Anyway, if you want to sell your software to other locales, you will
code your software with proper sensitivities.  If you want to buy
software that someone didn't want to sell you, well, you're got a
little bit of work to do.  And if you don't want to buy software that
someone didn't want to sell you, then why worry about it?

--
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp at relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-implementing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?



More information about the Comp.lang.c mailing list