- This topic has 15 replies, 2 voices, and was last updated 6 years, 3 months ago by HeDiBo.
-
AuthorPosts
-
June 1, 2018 at 11:15 am #37862HeDiBoParticipant
The text in the today button is only formatted in the American style: july 24, 2018 (it looks a bit silly, because the name of the month is in Dutch, where months are written with a small letter).
In my country (and many others) the format should be 24 july 2018.
The problem stems from this hard coded format in the initialization of TsMonthCalendar:
Code:FTodayBtn.Caption := s_Today + FormatDateTime(' mmmm d, yyyy', Date);June 1, 2018 at 1:58 pm #58021HeDiBoParticipantI think this would be a good replacement:
Code://FTodayBtn.Caption := s_Today + FormatDateTime(' mmmm d, yyyy', Date); (*** DB ***)
ds := FormatDateTime(FormatSettings.LongDateFormat, Date ); (*** DB ***)
FTodayBtn.Caption := s_Today + Copy(ds, Pos(' ', ds), 9999); (*** DB ***)June 4, 2018 at 1:22 pm #58038HeDiBoParticipantIn AC 13.16 you have replaced the month in letters by a short date format. That's a pity, because using the month in letters looks much better.
That's why I proposed the change in the way I did. It's language independent (provided the weekday name comes first in the format, which is universally true, I think)
Maybe the TranslateDateFormat function (in XE that's FormatSettings.TranslateDateFormat) could be a universal solution for displaying month in letters and day of the month and the year. I'm not sure how it actually works. Also it's a private class function, so some meddling is necessary.
June 6, 2018 at 9:44 am #58046SupportKeymasterHello!
LongDateFormat doesn't looks good in some other languages (ukrainian and russian are not Ok there).
So, I was decided to make a format like standard calendar while better solution is not found.
June 6, 2018 at 7:21 pm #58053HeDiBoParticipant'Support' wrote:Hello!
LongDateFormat doesn't looks good in some other languages (russian and ukrainian are not Ok there).
You're absolutely right. So, today I digged deep into internationalization and came up with this idea: eliminate the dddd from the LongDateFormat and use the new format in a FormatDateTime call.
I made a proof of concept. Only the Mongolian long date format does not work, so in that case I translate it to short date format.
The key to it all is the
function DropDayName(const fmtDateStr: String): String;
which takes a LongDateFormat as parameter and returns a date format where the dddd day name is eliminated.
If you press the ShowAll button it lists a table of formats and results for all language ID's from 1 to 255.
With the Locale ID spin edit you can enter any Locale ID you want to test, showing the results in the four fields to the right.
Error 87 is an invalid locale ID.
The updated project is attached below.
June 7, 2018 at 10:07 am #58054HeDiBoParticipantI updated the project, to show the language and country also.
June 20, 2018 at 4:53 am #58064SupportKeymasterThank you, I will research it.
July 17, 2018 at 1:49 pm #58178HeDiBoParticipant'Support' wrote:Thank you, I will research it.
Despite your efforts, the date string is broken now. It says: “d MMMM yyyy” for today. I wish you would test your source before releasing it.
The last statement in sDateUtils.DateToLongStr should read “Result := sf;” i.s.o. “Result := s”.
July 17, 2018 at 3:56 pm #58189SupportKeymasterInteresting situation occurred here.
I have changed your test-app for test of the DateToLongStr and this function was tested in some other applications including ASkinDemo.exe
And result of this function was correct because “s” and “sf” has equal value after the “GetDateFormat(LngID, 0, @SysTime, PChar(s), PChar(sf), Size)” executing.
You are right, “Result := s” must be changed to “Result := sf” in the next line.
But in all my tests these two variables has equal value, this is a reason why tests were Ok.
July 17, 2018 at 4:02 pm #58190SupportKeymasterLook what I mean, in the “Watch list”
July 17, 2018 at 4:03 pm #58191HeDiBoParticipant'Support' wrote:But in all my tests these two variables has equal value, this is a reason why tests were Ok.
This is strange indeed.
Apparantly in some cases, the format string changes to the result
July 17, 2018 at 4:11 pm #58193SupportKeymasterIf you have a time you can check this issue in the my original ASkinDemo.exe: http://www.alphaskin…s/askindemo.zip
MonthCalendar may be found at the last frame there (“Unsorted”).
We will know, this behavior is depended from compiler or from OS.
I have tested it now under Win 7 and Win 10, result is same, test works Ok with this error.
July 17, 2018 at 4:15 pm #58194HeDiBoParticipant'Support' wrote:If you have a time you can check this issue in the my original ASkinDemo.exe: http://www.alphaskin…s/askindemo.zip
MonthCalendar may be found at the last frame there (“Unsorted”).
We will know, this behavior is depended from compiler or from OS.
I have tested it now under Win 7 and Win 10, result is same, test works Ok with this error.
Tried it (i ran the exe directly from your zip file), got the same bug (I'm on Windows 10 Pro).
July 17, 2018 at 4:19 pm #58195SupportKeymasterDo you mean, calendar contains “d MMMM yyyy” there?
July 17, 2018 at 4:19 pm #58196HeDiBoParticipant'Support' wrote:Do you mean, calendar contains “d MMMM yyyy” there?
yes
July 28, 2018 at 10:07 pm #58250HeDiBoParticipantProblem solved in 13.18
-
AuthorPosts
- You must be logged in to reply to this topic.