::xotcl::Object
::xo::ical
The Object ::calendar::ical provides the methods for
importing and exporting single or multiple calendar items
in the ical format (see rfc 2445). Currently only the part
of ical is implemented, which is used by the mozilla
calendar (Sunbird, or Lightning for Thunderbird).
- Author:
- Gustaf Neumann
Defined in packages/xotcl-core/tcl/ical-procs.tcl
::xotcl::Object create ::xo::ical
Methods
proc clock_to_iso
::330608 proc clock_to_iso seconds {
clock format $seconds -format "%Y-%m-%dT%H:%M:%SZ" -gmt 1
}
proc clock_to_local_day
::330608 proc clock_to_local_day seconds {
clock format $seconds -format "%Y%m%d"
}
proc clock_to_oacstime
::330608 proc clock_to_oacstime seconds {
clock format $seconds -format "%Y-%m-%d %H:%M"
}
proc clock_to_utc
::330608 proc clock_to_utc seconds {
clock format $seconds -format "%Y%m%dT%H%M%SZ" -gmt 1
}
proc date_time_to_clock
::330608 proc date_time_to_clock {date time utc} {
set year [string range $date 0 3]
set month [string range $date 4 5]
set day [string range $date 6 7]
set hour [string range $time 0 1]
set min [string range $time 2 3]
set sec [string range $time 4 5]
set TZ [expr {$utc ? "GMT" : ""}]
return [clock scan "$year-$month-$day $hour:$min $TZ"]
}
::xo::ical
dates_valid_p -start_date start_date -end_date end_date
A sanity check that the start time is before the end time.
This is a rewrite of calendar::item::dates_valid_p, but
about 100 times faster.
- Switches:
- -start_date (required)
- -end_date (required)
::330608 proc dates_valid_p {-start_date:required -end_date:required} {
#my log "$start_date <= $end_date = [expr {[clock scan $start_date] <= [clock scan $end_date]}]"
expr {[clock scan $start_date] <= [clock scan $end_date]}
}
::xo::ical
ical_to_text text
Transform the escaped ical text format to plain text
- Parameters:
-
text
::330608 proc ical_to_text text {
regsub -all {\\(n|N)} $text \n text
regsub -all {\\(\\|\;|\,)} $text {\1} text
return $text
}
proc tcl_time_to_local_day
::330608 proc tcl_time_to_local_day time {
VALUE=DATE:[my clock_to_local_day [clock scan $time]]
}
proc tcl_time_to_utc
::330608 proc tcl_time_to_utc time {
clock format [clock scan $time] -format "%Y%m%dT%H%M%SZ" -gmt 1
}
::xo::ical
text_to_ical [ -remove_tags remove_tags ] text
Transform arbitrary text to the escaped ical text format
(see rfc 2445)
- Switches:
- -remove_tags (defaults to
"false"
) (optional)
- Parameters:
-
text
::330608 proc text_to_ical {{-remove_tags false} text} {
if {$remove_tags} {regsub -all {<[^>]+>} $text "" text}
regsub -all \n $text \\n text
regsub -all {(\\|\;|\,)} $text {\\\1} text
return $text
}
proc utc_to_clock
::330608 proc utc_to_clock utc_time {
clock scan $utc_time -format "%Y%m%dT%H%M%SZ" -gmt 1
}