Hello Alex,

Thanks for this message.

Le 09/10/2019 à 21:08, Alexander Burger a écrit :
Hi Eric,

thanks for sharing your code!

As far I could see on a first scan, it looks very good.


The result starts with "Wednesday" instead of
"Monday" as for the week 41 or other weeks!
The values have no inherent ordering, as they all have the same key (the
combination of year and day). So they may appear in any order, just by chance
starting on Monday (probably due to the order the objects were imported).
OK.
If you want to collect the days in order, you could just use the 'date' index,
and calculate the range from the week (I don't know that algorithm at the
moment. Assuming we had such functions, we could do

    (collect 'date '+Agenda (weekStart 2019 42) (weekEnd 2019 42))

This would be the most efficient way.
Hum...
Otherwise you could sort it

   (by '((This) (: date)) sort (collect 'year '+Agenda (2019 42)))

with a little more overhead.

Yes this works very well. Now, I have all my weeks sorted from monday to sunday.

My new functions to achieve this:

# print any database outputs as a table.
(de showData (DBOutputs)
   (let Fmt *Params
      (tab Fmt "id" "date" "mag" "year" "mthnum" "mthtxt" "week" "daynum" "daytxt" "status")       (tab Fmt "--------" "------" "------" "----" "------" "------" "----" "------" "------" "------")
      (for This DBOutputs
         (tab Fmt (: id) (: date) (: mag) (: year) (: monthnum)
                  (: monthtxt) (: week) (: daynum) (: daytxt) (: status) ) ) ) )

# show a given week sorted by date.
# usage: (showThisWeek 2019 42)
(de showThisWeek (Year Week)
   (showData (by '((This) (: date)) sort (collect 'year '+Agenda (list Year Week)))) )

Best,

Eric


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to