|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 6 of 6 total|
|Couple of questions regarding dates|
|Sun, May 6 2018 11:31 PM||Permanent Link|
In my main forms on create event, I have the following:
//date format options
FormatSettings.ShortDateFormat := 'd/MM/yyyy';
1. What do I need to do (if anything) to tell the app to use the local date settings? So if in the US M/D/Y or if in Australia D/M/Y.
2. If I manually type in the date 7/5/18, I get displayed: 7/05/1918
How do I make sure manually entered 2 digit years become 20XX ?
|Mon, May 7 2018 7:12 AM||Permanent Link|
Just assign new values to the FormatSettings properties in the initialization section of your main form.
|Mon, May 7 2018 9:45 AM||Permanent Link|
1. If you want to set the format without user interaction, you would need some kind of geolocation and a list of formats per country. Not the easiest task.
2. Take a look at (T)FormatSettings.TwoDigitYearCenturyWindow.
|Thu, May 10 2018 5:52 PM||Permanent Link|
>> 2. Take a look at (T)FormatSettings.TwoDigitYearCenturyWindow.
Thanks for the answers. I have read and re-read the help file description on the TwoDigitYearCenturyWindow property, and really don't understand exactly how this works.
What I would like to end up with is:
years entered as 00 up to current year (18) + 5 (so 23) are interpreted as 20XX
years entered as 24 up to 99 are interpreted as 19XX
What value do I need in the TwoDigitYearCenturyWindow property to do this?
|Fri, May 11 2018 5:10 AM||Permanent Link|
Strange... I tried this code:
for i := -100 to 100 do begin
FormatSettings.TwoDigitYearCenturyWindow := i;
s1 := DateToStr(StrToDate('02.03.23'));
s2 := DateToStr(StrToDate('02.04.24'));
logoutput(inttostr(i) + ' ' + s1 + ' ' + s2);
And all I get is "02.03.1923 02.04.1924". It seems that Tim should take a look.
|Fri, May 18 2018 2:10 PM||Permanent Link|
Tim Young [Elevate Software]
Elevate Software, Inc.
<< Strange... I tried this code: >>
The issue is that the TwoDigitYearCenturyWindow logic only kicks in when the year format for the date format is 'yy', not when it's 'yyyy'. I've modified this for B13 so that it kicks in when the *specified* year is a partial year.