AltME: REBOL3

Messages

Gregg
Watch for boundary issues. Here are a couple helpers that show what I mean.
set 'last-day-of-month func [date /local d] [
    d: date
    d/day: 1
    d/month: d/month + 1
    d: d - 1
    d
]
set 'same-day-next-month func [date /local d] [
    d: date
    d/month: d/month + 1
    if d/day < date/day [d: d - d/day]
    d
]
GiuseppeC
Ashley, how if I need to calculate a generic monday of N weeks AGO
or
sunday of N weeks in the future ?
Gregg
What have you tried so far Giuseppe?
GiuseppeC
I am currently working on it on the consolle
GiuseppeC
dayofweek: 1
date:  either now/weekday = dayofweek [now - (7 * (weeks - 1))] [now - (((7 * (weeks - 1)) - either now/weekday = 1 [now - (7 * (weeks - 1))] [now - (((7 * (weeks - 1)) -  dayofweek) + now/weekday)]
GiuseppeC
Ooops... to many copies
The following code returns the dayofweek of /weeks/ ago
        dayofweek: 1
        weeks: 2
        date: either now/weekday = dayofweek
            [now - (7 * (weeks - 1))]
            [now - (((7 * (weeks - 1)) -  dayofweek) + now/weekday)]
GiuseppeC
Note that this formula is dangerous when you want to filter something from a start to and date because it includes TIME!
now should be changed to now/date
DideC
I have a generic calculation for dates:   date-of-monday: a-date + 1 - a-date/weekday
If you need a sunday, it become:   date-of-sunday: a-date + 7 - a-date/weekday
Then just add or remove (weeks  * 7)

GiuseppeC
Interesting
Arnold
What should same-day-next-month be today?

Gregg
That would be open to interpretation on a day like today. My call, when I wrote that func, was to use the last day of the month, if the next month has less days than the target month.
Alternately, you could throw an error or return none.
Arnold
Yes depends on what you want it to be.

Ashley
>> col: 1
>> do z: compose/deep [foreach row [[A]] [(to-path join "row/" col)]]
** Script error: cannot access end! in path row/1
** Where: foreach do
** Near: foreach row [[A]] [row/1]
>> z
== [foreach row [[A]] [row/1]]
>> type? first p: [row/1]                                
== path!
>> do z: compose/deep [foreach row [[A]] [(pick p col)]]
== A
>> z
== [foreach row [[A]] [row/1]]
How to get first example working? ... and then for set-path! (i.e. row/1:)
DocKimbel
TO-PATH on a string! value is not doing what you expect:
>> length? to-path "a/b"
== 1
Just replace it with LOAD and it will work fine.
And alternative way to achieve it without using strings: (append to-path 'row col)
Ashley
Wow, the append approach is pretty neat (works with to-set-path as well). Thanks.

GrahamC
For those who don't follow the progress of Ren-c, there have been some changes.  We are currently working on reaching r2 parity.  See https://trello.com/c/5K0ZKkrg/92-bringing-ren-c-to-parity-with-rebol2
I knocked off prot-smtp, prot-send and prot-pop3 recently based on the work I did many years ago.  But also did a prot-synctcp https://github.com/gchiu/Rebol3/blob/master/protocols/prot-synctcp.reb

Last message posted 161 weeks ago.