Is there a programmatic way to get short names in windows?

Is there a way to get a 2-digit day of the week, for example MO / TU / WE / TH / FR / SA / SU?

Currently, I only know about using FormatDateTime ():

 "ddd" returns "Fri"
 "dddd" returns "Friday"

The main reason is because I want to get a localized version of the day names in 1 or 2 characters:

Say that FRIDAY in "ddd" will return:
French Windows = "Vendredi", 2 char will be "VE", pay attention to the 1st and 2nd char.
Chinese Windows = "星期五", char will be "五", pay attention to the third char.
Japanese Windows = "金曜日", char will be "金", pay attention to 1st char.

Edit1: Currently used by Delphi, but I think this applies to other languages ​​as well.

Edit2: Simply put, I'm looking to get a shorter version of “ShortDayName” with some functions or constants, so I don’t need to create a constant table containing a 7-day “Short” for all possible Windows languages.

I wonder if such functions really exist. Perhaps calendar names of 1 or 2 char days in Outlook are hard-coded, right?

+3
source share
3 answers

ShortDayNames LongDayNames, DayOfWeek, .

ShortDayNames[Index]; //Returns Fri

LongDayNames[Index]; //Returns Friday

, , , -

LeftStr(LongDayNames[Index],2);//Returns Fr

,

LeftStr(LongDayNames[DayOfWeek(date)],2); //Returns Fr
+3

.

"ddd" .

+2

Delphi - . : . MSDN this.

, , "2- -" "3- -". Delphi : native ( "long" ), ( "" Delphi) (Vista , Delphi) .

, : (3 , en-US), (2 , ru-RU).

, , , LOCALE_SSHORTESTDAYNAMEX ( "" MSDN Delphi), Vista .

, :

const
  LOCALE_SSHORTESTDAYNAME1 = $60;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetThreadLocale($409);
  ShowMessage(
    GetLocaleStr(GetThreadLocale, LOCALE_SSHORTESTDAYNAME1, '') + #13#10 +
    GetLocaleStr(GetThreadLocale, LOCALE_SABBREVDAYNAME1, '')
             );
end;

:

:

, ;)

+1

Source: https://habr.com/ru/post/1714050/


All Articles