I've again (again reinventing the wheel) coded a unix-like "cal" program, this time using fb. Then/later I was asked if I could "internationalize" my code; my response was somewhat more severe than "NO". Below is a qualified "Yes" (proof code), after some thought;

The code should print a localized month calendar to console (which means that it can be cut/pasted, which is the ONLY reason I have for reinventing text calendars). You should see a Monday-start week calendar if your locale specifies this, Sunday-first if not.

There is no single API function to do it, but it can be done with the current API. Use this at your own risk, and you really should backup your registry before you start playing with it. I always do ;)

Note that I'm arbitrarily forcing/truncating the abbreviated daynames to 3 chars. M$ implies that a "ddd" format dayname returned by GetDateFormat will always be 3 chars - wrong, my minimal testing showed a range of 2 (e.g., German) to 4 (don't rem what lang that was, it was 3 chars + period). Later M$ offers a method to get short abbreviated daynames (heh). I don't know (can't understand) what impact my truncation has on Arabic (or???). My original English-only version uses 2 chars, allowing for a more compact (square) calendar.

Note that GetDateFormat will not work for years<1601. The underlying code (modified-modified Zeller) is accurate to 01-01-01 as-is (with exception of the year<1583 11 day Gregorian fudge).

@voodooattack

Your Unicode mod is great. I had considered this but didn't think I'd be able to test it. Wrong, works fine with standard codepage in XP console (and with, for example, an Italian calendar).

@MichaelW

Kewl, reghacks. Beware the faint of heart.

-----

Ok, now I'll try to stuff this back into my "cal" code. Another half-day on the (reinvented) wheel..

voodooattack wrote:well the longest weekday name in arabic is 9 characters.. :)

and we never use "short abbreviated daynames" in arabic ;D

what impact my truncation has on Arabic

ruins it ;)

a good strategy would be enumerating all the daynames, and using the largest width as the column width.. :)

...

Heh. A good strategy is to pander to those who might use my product. And since I'm not selling (a product) .. But your point is valid, even if I stubbornly stick with 3 char daynames. I would think that any presentation of sequential numbers in 7xn format with a discernible monthname header could be interpreted as a calendar, particularly if you are told it is a calendar. Numbers alone should be sufficient. Left to right or right to left?

I didn't have time to fold voodoo's unicode mods into my fb-"cal" code. I did flop this interactive cal together:

dstr=left(trim(dstr),3) daystring = daystring & dstr & space(4-len(dstr)) nextend if print:print " ";daystring' if std<>6 then sdow-=1: if sdow<0 then sdow=6:end if end if a = 1-sdow:c=0 while a<=ndays if a>=1 then if yy=ny and mm=nm then color iif(a=dd,15,7),0 end if print using "####";a; else print space(4); end if a+=1:c+=1 if c=7 then c=0:print:end if wend'if yy=ny and mm=nm and dd=nd then stime.wYear=yy stime.wMonth=mm stime.wDay=dd dstr=wstr(space(256)) GetDateFormat(LOCALE_USER_DEFAULT,_ DATE_LONGDATE,_ @stime,_ NULL,_ (dstr),_ sizeof(dstr))

dstr=trim(dstr) if len(dstr)>maxlen then maxlen=len(dstr) da(d)=dstr next maxlen+=1 dim ts as wstring * 32 for d=1 to 7 ts=wstr(space(maxlen-len(da(d)))) & da(d) daystring=daystring & ts next daystring=ltrim(daystring)end if print:print " ";daystring' if std<>6 then sdow-=1: if sdow<0 then sdow=6:end if end if a = 1-sdow:c=0 while a<=ndays if a>=1 then if yy=ny and mm=nm then color iif(a=dd,15,7),0 end if print space(maxlen-len(str(a)));str(a); else print space(maxlen); end if a+=1:c+=1 if c=7 then c=0:print:end if wend'

The only language I can find installed on (my) XP to test that returns variable length abbreviated daynames is Sami, Northern [Finland]:

If you MUST have full daynames add another "d":-->fstr=wstr("dddd")reverse the spacing:-->ts=wstr(space(maxlen-len(da(d)))) & da(d)and then comment:-->' daystring=ltrim(daystring)and you'll have a really LONG calendar that will probably wrap the console..

A side note: I caused the abbreviated daystring creation to occur only once (in the original interactive cal), not for efficiency but because it (GetDateFormat) would explode on the 35th call (* 7 days), then segmentation fault on the 36th. Consistently. I'm hoping the other calls don't follow this pattern.. I've leaned on right-arrow to year 2100 without explosions..