Class Relations
- class: ::nx::EnsembleObject
::nx::EnsembleObject create ::xo::ical::VCALITEM::slot::__parse
Methods (to be applied on the object)
RRULE (scripted)
set r_freq ""
set every_n 1
set r_error 0
set r_until ""
set days_of_week ""
set r_count 0
foreach rval [split $recurrule ";"] {
if { [regexp {^FREQ\=+(.*)$} $rval _ freqval] } {
switch $freqval {
DAILY { set r_freq "day" }
WEEKLY { set r_freq "week" }
MONTHLY { set r_freq "month_by_day"}
YEARLY { set r_freq "year"}
default { set r_error 1 }
}
} elseif { [regexp {^COUNT=(.*)$} $rval _ countval] } {
set r_count $countval
} elseif { [regexp {^UNTIL=([0-9]+)(T([0-9]+)Z?)?$} $rval _ untildate untiltime] } {
if {$untiltime eq ""} {
set untiltime 000000
}
append r_until "[string range $untildate 0 3]-[string range $untildate 4 5]-[string range $untildate 6 7]" " " "[string range $untiltime 0 1]:[string range $untiltime 2 3]"
} elseif { [regexp {^INTERVAL\=+(.*)$} $rval _ intval] } {
set every_n $intval
} elseif { [regexp {^BYDAY\=+(.*)$} $rval _ bydayval] } {
foreach dayval [split $bydayval ","] {
switch $dayval {
SU { lappend days_of_week "0" }
MO { lappend days_of_week "1" }
TU { lappend days_of_week "2" }
WE { lappend days_of_week "3" }
TH { lappend days_of_week "4" }
FR { lappend days_of_week "5" }
SA { lappend days_of_week "6" }
}
}
} elseif { [regexp {^BYMONTHDAY\=+(.*)$} $rval _ bymonthdayval] } {
set r_freq "month_by_date"
} else {
:debug "ignore recurrence rule <$rval> of <$recurrule>"
}
}
if { $r_until eq "" && $r_freq ne "" && $r_count > 0 } {
switch $r_freq {
day { set r_freq_amount 86400 }
week { set r_freq_amount 604800 }
month_by_day { set r_freq_amount 2419200 }
month_by_date { set r_freq_amount 2678400 }
year { set r_freq_amount 31449600 }
}
set r_count [expr {$r_count - 1}]
set r_extra [expr {$r_count * $r_freq_amount * $every_n}]
if { $r_freq eq "week" && [llength $days_of_week] > 0} {
set r_extra [expr {$r_extra / [llength $days_of_week]}]
}
set r_until [::xo::ical clock_to_oacstime [expr {[clock scan ${:dtstart}] + $r_extra}]]
}
if { !$r_error && $r_freq ne ""} {
set :recurrence_options [list -interval_type $r_freq -every_n $every_n]
if {$days_of_week ne ""} {
lappend :recurrence_options -days_of_week $days_of_week
}
if {$r_until ne ""} {
lappend :recurrence_options -recur_until $r_until
}
}