View Issue Details

IDProjectCategoryView StatusLast Update
0037955FPCRTLpublic2021-02-19 09:15
ReporterDragisa Maksimovic Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
PlatformMac MiniOSMac OS 
Product Version3.2.0 
Summary0037955: formatSettinngs.LongDayNames[ DayFriday] returns "Thursday"
DescriptionformatSettinngs.LongDayNames[ DayFriday] returns "Thursday"
Steps To ReproduceformatSettinngs.LongDayNames[ DayFriday] returns "Thursday"
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

delfion

2020-10-19 08:23

reporter   ~0126410

DayMonday = 1;
writeln(FormatSettings.LongDayNames[1]) => Sunday

Michael Van Canneyt

2020-10-19 09:01

administrator   ~0126411

The dayNNN constants in dateutils do not represent indexes for the DayNames array.
They are constants for the ISO date numbering, so this is normal.

Dragisa Maksimovic

2021-02-19 06:07

reporter   ~0129008

If it is a bug - make it feature.. No Michael, it is a bug. If formatSetting.LongDayNames does not accept name constants from dateutils, then compiler should pick it up.

Michael Van Canneyt

2021-02-19 09:15

administrator   ~0129011

I agree the constants are confusing. Blame Delphi, we inherited this from them:
DateUtils tries to be ISO compliant, SysUtils is based on the conventions used in the USA. You should not mix them.

The compiler cannot catch this, because a constant is just a number. You can even use meaningless constants.
The compiler will only warn you when you use a constant that is out of range:

fpc -Cr tb.pp
tb.pp(4,41) Error: Range check error while evaluating constants (8 must be between 1 and 7)
tb.pp(5,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode
home:~> cat tb.pp
uses sysutils,dateutils;

begin
    Writeln(FormatSettings.LongDayNames[monthAugust]);
end.

Issue History

Date Modified Username Field Change
2020-10-19 01:40 Dragisa Maksimovic New Issue
2020-10-19 08:23 delfion Note Added: 0126410
2020-10-19 09:01 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-10-19 09:01 Michael Van Canneyt Status new => resolved
2020-10-19 09:01 Michael Van Canneyt Resolution open => no change required
2020-10-19 09:01 Michael Van Canneyt FPCTarget => -
2020-10-19 09:01 Michael Van Canneyt Note Added: 0126411
2021-02-19 06:07 Dragisa Maksimovic Note Added: 0129008
2021-02-19 09:15 Michael Van Canneyt Note Added: 0129011