TsMonthCalendar shows today in wrong format

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #37862
    HeDiBo
    Participant

    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);
    #58021
    HeDiBo
    Participant

    I 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 ***)
    #58038
    HeDiBo
    Participant

    In 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.

    #58046
    Support
    Keymaster

    Hello!

    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.

    #58053
    HeDiBo
    Participant
    '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.

    #58054
    HeDiBo
    Participant

    I updated the project, to show the language and country also.

    #58064
    Support
    Keymaster

    Thank you, I will research it.

    #58178
    HeDiBo
    Participant
    '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. dry.gif

    The last statement in sDateUtils.DateToLongStr should read “Result := sf;” i.s.o. “Result := s”.

    #58189
    Support
    Keymaster

    Interesting 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.

    #58190
    Support
    Keymaster

    Look what I mean, in the “Watch list”

    #58191
    HeDiBo
    Participant
    '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 ohmy.gif

    #58193
    Support
    Keymaster

    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.

    #58194
    HeDiBo
    Participant
    '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).

    #58195
    Support
    Keymaster

    Do you mean, calendar contains “d MMMM yyyy” there?

    #58196
    HeDiBo
    Participant
    'Support' wrote:

    Do you mean, calendar contains “d MMMM yyyy” there?

    yes

    #58250
    HeDiBo
    Participant

    Problem solved in 13.18 a3.gif

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.