i would like to have constants for the DayOfWeek() function. Something like this:
Code: Select all
Enumeration
#Sunday
#Monday
#Tuesday
#Wednesday
#Thursday
#Friday
#Saturday
EndEnumeration
Uwe
Code: Select all
Enumeration
#Sunday
#Monday
#Tuesday
#Wednesday
#Thursday
#Friday
#Saturday
EndEnumeration
No, please!uwekel wrote:i would like to have constants for the DayOfWeek() function. Something like this:
Code: Select all
Enumeration #Sunday #Monday #Tuesday #Wednesday #Thursday #Friday #Saturday EndEnumeration
Code: Select all
Enumeration 1
#Monday
#Tuesday
#Wednesday
#Thursday
#Friday
#Saturday
#Sunday
EndEnumeration
Procedure IsoDayOfWeek (d)
Protected w = DayOfWeek(d)
If w = 0
w = 7
EndIf
ProcedureReturn w
EndProcedure
If IsoDayOfWeek(d) = #Sunday
; [...]
EndIf
Yes, of course.uwekel wrote:My proposal is just according to PB's DayOfWeek() function.
Then just write an Enumeration like the one in your first post above, and all is fine.uwekel wrote:For me it is not that important to be ISO conform.
Code: Select all
Enumeration
#PB_Sunday
#PB_Monday
#PB_Tuesday
#PB_Wednesday
#PB_Thursday
#PB_Friday
#PB_Saturday
EndEnumeration
This sentence is completely wrong.ts-soft wrote:It is completely irrelevant which internal number is used there.
It is simple enough to wrap whatever the constants are, and it would make more sense than "If w = 7: w = 0: EndIf".Little John wrote:In this situation, adding any built-in constants for the weekday will be a disimprovement.
Code: Select all
; ;proposed pre-defined constants
; Enumeration
; #PB_Sunday
; #PB_Monday
; #PB_Tuesday
; #PB_Wednesday
; #PB_Thursday
; #PB_Friday
; #PB_Saturday
; EndEnumeration
Enumeration
#ISO_Monday = 1
#ISO_Tuesday
#ISO_Wednesday
#ISO_Thursday
#ISO_Friday
#ISO_Saturday
#ISO_Sunday
EndEnumeration
Procedure IsoDayOfWeek (d)
Protected w
Select DayOfWeek(d)
Case #PB_Sunday
w = #ISO_Sunday
Case #PB_Monday
w = #ISO_Monday
Case #PB_Tuesday
w = #ISO_Tuesday
Case #PB_Wednesday
w = #ISO_Wednesday
Case #PB_Thursday
w = #ISO_Thursday
Case #PB_Friday
w = #ISO_Friday
Case #PB_Saturday
w = #ISO_Saturday
EndSelect
ProcedureReturn w
EndProcedure
If IsoDayOfWeek(d) = #ISO_Sunday
; [...]
EndIf
It is a matter of course, that the number of the first day of the week has to be smaller than the number of the second day of the week. And the number of the second day of the week has to be smaller than the number of the third day of the week etc. Thus, if Monday is the first day of the week, you obviously can not have Monday=1, Tuesday=2 ... Sunday=0.ts-soft wrote:The ISO 8601 says only, Monday is the first Day of the week, but not Monday is numbered to 0 or 1.
In PB stays 0 for Sunday and not for FirstDayOfWeek.
IMHO it's simpler and less confusing just to let it as is.Demivec wrote:It is simple enough to wrap whatever the constants are, and it would make more since then "If w = 7: w = 0: EndIf".Little John wrote:In this situation, adding any built-in constants for the weekday will be a disimprovement.
+1. All the other discussion is just silly. We just want constants to match the values in the Help file.uwekel wrote:i would like to have constants for the DayOfWeek() function.
When my oldest son was 4 years old he asked, "What day came before the first Monday?", and was only satisfied after we had spent an hour or so discussing various mathematical concepts. Ultimately, he went on to take a degree in mathematics.Little John wrote:It is a matter of course, that the number of the first day of the week has to be smaller than the number of the second day of the week. And the number of the second day of the week has to be smaller than the number of the third day of the week etc. Thus, if Monday is the first day of the week, you obviously can not have Monday=1, Tuesday=2 ... Sunday=0.
I'm so glad that we have talked about it.BorisTheOld wrote:I think my 4 year old son might have argued that if Monday = 1, then there's a good case to be made for assigning Sunday = 0.