Object ::xo::ical (public)
::nx::Object ::xo::ical
Defined in packages/xotcl-core/tcl/01-debug-procs.tcl
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
- ::xo::ical::VCALENDAR
- ::xo::ical clock_to_iso /seconds/
- ::xo::ical reflow_content_line /text/
- ::xo::ical date_time_to_clock /date/ /time/ /utc/
- ::xo::ical clock_to_oacstime /seconds/
- ::xo::ical tcl_time_to_local_day /time/
- ::xo::ical clock_to_local_day /seconds/
- ::xo::ical tcl_time_to_utc /time/
- ::xo::ical::VEVENT
- ::xo::ical utc_to_clock /utc_time/
- ::xo::ical clock_to_utc /seconds/
- ::xo::ical::VTODO
- ::xo::ical::VCALITEM
- ::xo::ical dates_valid_p -start_date /value/ -end_date /value/
- ::xo::ical ical_to_text /text/
- ::xo::ical text_to_ical ?-remove_tags /boolean/? /text/
- Testcases:
- No testcase defined.
Source code: :object method debug {msg} { # # TODO: maybe add Debug(ical)? # ns_log Debug(caldav) "[uplevel current proc]: $msg" } # # Conversion routines from and to the date formats used by ical # :public object method date_time_to_clock {date time utc} { # # Convert separate fields date and time with boolean utc flags # into clock value in seconds. # 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"] } :public object method tcl_time_to_utc {time} { # # Convert Tcl time stamp to UTC. # clock format [clock scan $time] -format "%Y%m%dT%H%M%SZ" -gmt 1 } :public object method tcl_time_to_local_day {time} { # # Convert Tcl time stamp into local day format # https://tools.ietf.org/html/rfc5545#section-3.3.4 # return "VALUE=DATE:[:clock_to_local_day [clock scan $time]]" } :public object method utc_to_clock {utc_time} { # # Convert UTC time to clock seconds. # clock scan $utc_time -format "%Y%m%dT%H%M%SZ" -gmt 1 } :public object method clock_to_utc {seconds:integer} { # # Convert clock epoch (result from [clock seconds]) into UTC time. # clock format $seconds -format "%Y%m%dT%H%M%SZ" -gmt 1 } :public object method clock_to_iso {seconds:integer} { # # Convert clock epoch (result from [clock seconds]) into ISO format # clock format $seconds -format "%Y-%m-%dT%H:%M:%SZ" -gmt 1 } :public object method clock_to_local_day {seconds:integer} { # # Convert clock epoch (result from [clock seconds]) to local day (YearMonthDay) # clock format $seconds -format "%Y%m%d" } :public object method clock_to_oacstime {seconds:integer} { # # Convert clock epoch (result from [clock seconds]) into time # format usually used in OpenACS. # clock format $seconds -format "%Y-%m-%d %H:%M" } :public object method dates_valid_p { -start_date:required -end_date:required } { # 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. # #my log "$start_date <= $end_date = [expr {[clock scan $start_date] <= [clock scan $end_date]}]" expr {[clock scan $start_date] <= [clock scan $end_date]} } :public object method text_to_ical {{-remove_tags:boolean false} text} { # # Transform arbitrary text to the escaped ical text format # (see rfc 2445) # if {$remove_tags} { regsub -all {<[^>]+>} $text "" text } regsub -all {(\\|\;|\,)} $text {\\\1} text regsub -all \n $text {\\n} text return $text } :public object method ical_to_text {text} { # # Transform the escaped ical text format to plain text # regsub -all {\\(n|N)} $text \n text regsub -all {\\(\\|\;|\,)} $text {\1} text return $text } :public object method reflow_content_line {text} { # # Perform line folding: According to RFC 5545 section 3.1, # SHOULD NOT be longer than 75 octets, excluding the line break. # https://www.ietf.org/rfc/rfc5545.txt # if {[string length $text] > 73} { set lines "" while {[string length $text] > 73} { append lines [string range $text 0 73] \r\n " " set text [string range $text 74 end] } append lines $text set text $lines } return $text }XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)