[comp.lang.c] Dates & things in C

d88-jwa@nada.kth.se (Jon W{tte) (05/31/89)

A propos dates, a small comment: Most American programmers seem not
to have noticed that there is a world OUTSIDE the U.S. of A. Many
international (read european) programmers include flexible date and
time formats in their programs, but how many american ditto do ?

I'm NOT saying that American programmers are bad, ugly or even narrow-
minded, I just want to make ALL people aware of the need to interna-
tionalize their programs. Tools for this will soon be available in UNIX,
but I doubt that they will be used. The Macintosh computers have had
the international resources for quite some time now, but still not
everybody use them (Read: M*crosoft, MS W*rd)

-- 
 __       Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se
/  \      (+46 (0) 8 258 268)
   /---   (c) 1989 Yessbox Allright Professional Products Inc. - Y.A.P.P.I.
  /       -- No More --

cramer@optilink.UUCP (Clayton Cramer) (06/02/89)

In article <1128@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon W{tte) writes:
> A propos dates, a small comment: Most American programmers seem not
> to have noticed that there is a world OUTSIDE the U.S. of A. Many
> international (read european) programmers include flexible date and
> time formats in their programs, but how many american ditto do ?
> 
> I'm NOT saying that American programmers are bad, ugly or even narrow-
> minded, I just want to make ALL people aware of the need to interna-
> tionalize their programs. Tools for this will soon be available in UNIX,
> but I doubt that they will be used. The Macintosh computers have had
> the international resources for quite some time now, but still not
> everybody use them (Read: M*crosoft, MS W*rd)
> 
>  __       Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se

Speaking of internationalization, what is the second character of
your name?  All I get is a left bracket.

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. :-)
-- 
Clayton E. Cramer {pyramid,pixar,tekbspa}!optilink!cramer
"He chose...poorly." -- Indiana Jones & The Last Crusade
----------------------------------------------------------------------------
Disclaimer?  You must be kidding!  No company would hold opinions like mine!

d88-jwa@nada.kth.se (Jon W{tte) (06/03/89)

In article <1604@optilink.UUCP> cramer@optilink.UUCP (Clayton Cramer) writes:
>In article <1128@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon W{tte) writes:
>>  __       Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se

>Speaking of internationalization, what is the second character of
>your name?  All I get is a left bracket.

It IS a left bracket! Or, if you are running on a machine with
Swedish ASCII font translation, its an a with two dots over it,
pronounced a bit like the E in WET (you know, not dry...)

>    #ifdef AMERICA
>        sprintf(Buffer, "%s-%02d-%02d", MonthStr, Date, Year);
>    #else /* BENIGHTEDPARTSOFWORLD */
>        sprintf(Buffer, "%02d-%s-%02d", Date, MonthStr, Year);
>    #endif

Aheum... A good start, but a widely used date format is YY MM DD, that
is:
	sprintf(Buffer, "%02d.%02d.%02d", Year, Month, Date);

Of course, any Real Programmer :-) defines a macro GimmeDaDateIn(Buffer)
that is selectively defined in the define part... Like you do in the
above example.

>Clayton E. Cramer {pyramid,pixar,tekbspa}!optilink!cramer
>"He chose...poorly." -- Indiana Jones & The Last Crusade
>----------------------------------------------------------------------------
>Disclaimer?  You must be kidding!  No company would hold opinions like mine!

Keep up the good work, Cramer!


-- 
 __       Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se
/  \      (+46 (0) 8 258 268)
   /---   (c) 1989 Yessbox Allright Professional Products Inc. - Y.A.P.P.I.
  /       -- No More --

diamond@diamond.csl.sony.junet (Norman Diamond) (06/05/89)

In article <1604@optilink.UUCP> cramer@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@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?

mcdonald@uxe.cso.uiuc.edu (06/06/89)

>
>    #ifdef AMERICA
>        sprintf(Buffer, "%s-%02d-%02d", MonthStr, Date, Year);
>    #else /* BENIGHTEDPARTSOFWORLD */
>        sprintf(Buffer, "%02d-%s-%02d", Date, MonthStr, Year);
>    #endif
>

NO NO NO NO NO NO!!!!!!!!!!

PLEASE:

    #ifdef AMERICA
        sprintf(buffer, "%s-%02d-%04d",monthstring[month], date, year);
    #else /*Pretty soon all your oxygen will come from the forests of
           North America! */
        sprintf(buffer, "%02d-%s-%04d",date,monthstring[month],year);
    #endif  /*                     ^          
                                   ^
                                   ^
                                   ^   */ 

Note the "4"!!!!

Doug McDonald