derbrill / libdate

liveCode library to handle date and time functions
7 stars 7 forks source link

libDate_dayOfWeek question #15

Open macMikey opened 5 years ago

macMikey commented 5 years ago

Why not pick off the last item of dateItems for this routine instead of doing all the work that you do? I think that code would be something like

function libDate_dayOfWeek pYear,pMonth,pDay
   put pYear,pMonth,pDay,0,0,0,0 into theDate
   convert theDate to dateItems
   return last item of theDate -1 #dateItems goes 1..7 for Sun..Sat
end libDate_dayOfWeek
derbrill commented 5 years ago

Because the whole idea of libDate is to avoid convert, due to century cutoff and epoch timestamp problems you may or may nnot be facing when needing to work with dates either before 19670 or after 2030. :-)