Packageardisia.scheduling.iCalendarParser
Classpublic class iCalendarParser
InheritanceiCalendarParser Inheritance Object

Both (A) exports an iCalendarData object to an an iCalendar formatted string and (B) imports an iCalendar formatted string and converts it to an iCalendarData object.

Exported data uses UTC time for everything to avoid timezone definitions due to flash timezone limitations.

Importing iCalendar strings will accept events in specific timezones as long as the string complies with the iCalendar spec and describes the timezone UTC offset for both standard and daylight savings. VTIMEZONE definitions should appear above VEVENTS.

Supports only 1 standard and 1 daylight savings definition per timezone.

There is only minimal error checking for imported feeds, so be sure the feed complies with the iCalendar spec. 1 Calendar per feed.

View the technical documentation on the Ardisia Labs website for more information.



Public Methods
 MethodDefined By
  
[static] Returns a iCalendar formatted string for the iCalendarData object.
iCalendarParser
  
[static] Accepts an iCalendar formatted string and returns a iCalendarData object.
iCalendarParser
Protected Methods
 MethodDefined By
  
decodeRrule(newSchedulingData:SchedulingData, str:String, timeZones:Array):void
[static] Accepts an iCalendar formatted RRULE string and parses the appropriate SchedulingData properties.
iCalendarParser
  
decodeTimeZoneProperty(timeZone:TimeZone, str:String, inDstDefinition:Boolean):void
[static] Reads a property/value pair from a vtimezone definition and parses TimeZone properties.
iCalendarParser
  
escapeChars(str:String):String
[static] iCalendar spec requires escaping of commas, colons, and semicolons.
iCalendarParser
  
fixOverflow(str:String):String
[static] iCalendar spec expects lines no longer than 75 characters.
iCalendarParser
  
getDayNum(dayStr:String):int
[static] Converts a iCalendar string representation of a day of the week into an actionscript numerical representation of the day of a week.
iCalendarParser
  
getDayString(dayNum:int):String
[static] Converts an actionscript numerical representation of a day of the week into an iCalendar string representation of the day of a week.
iCalendarParser
  
getDecodedDate(str:String, timeZones:Array = null):Date
[static] Decodes iCalendar formatted DATE or DATE-TIME values into as3 Dates.
iCalendarParser
  
getICalendarDateStamp(date:Date):String
[static] Converts a Date object to an iCalendar formatted string for "floating time", E.G.
iCalendarParser
  
getICalendarTimeStamp(date:Date):String
[static] Converts a Date object to an iCalendar formatted timestamp string.
iCalendarParser
  
getOccurrenceDay(year:int, month:int, day:int, interval:int):int
[static] Get the day.
iCalendarParser
  
readVEventProperty(newSchedulingData:SchedulingData, line:String, timeZones:Array):void
[static] Decodes a property line contained within a VEVENT and updates the passed SchedulingData object.
iCalendarParser
  
unfoldAndEscape(str:String):String
[static] Unfolds string by removing > 75 char line breaks and unescapes commas, colons, and semi-colons.
iCalendarParser
Method Detail
decodeRrule()method
protected static function decodeRrule(newSchedulingData:SchedulingData, str:String, timeZones:Array):void

Accepts an iCalendar formatted RRULE string and parses the appropriate SchedulingData properties.

Parameters

newSchedulingData:SchedulingData — the SchedulingData object being updated
 
str:String — the RRULE string
 
timeZones:Array — array of defined time zones

decodeTimeZoneProperty()method 
protected static function decodeTimeZoneProperty(timeZone:TimeZone, str:String, inDstDefinition:Boolean):void

Reads a property/value pair from a vtimezone definition and parses TimeZone properties. Assumes only 1 standard and/or daylight savings definition. If multiple, only the last timezone will be used.

DTSTART is ignored, so if you need multiple time zone definitions, or definitions that only applied in the past, this method will need to be extended.

RRULE is used to define the onset of observance of daylight savings and standard time. All the timezones I have seen use an RRULE.

FYI, Asia doesn't observe daylight savings. Basically, only North America and Europe observe daylight savings. The USA, Canada and Mexico observe a general rule of the second Sunday in March and on the first Sunday in November. Europe generally observes the last Sunday in March and ending on the last Sunday in October.

Parameters

timeZone:TimeZone — the TimeZone properties to update
 
str:String — the iCalendar formatted line to parse
 
inDstDefinition:Boolean — a Boolean whether the parsed property is within a dst definition

escapeChars()method 
protected static function escapeChars(str:String):String

iCalendar spec requires escaping of commas, colons, and semicolons.

Parameters

str:String — the String to escape

Returns
String — escaped string
exportICalendar()method 
public static function exportICalendar(calData:iCalendarData):String

Returns a iCalendar formatted string for the iCalendarData object.

Parameters

calData:iCalendarData — the iCalendarData

Returns
String — iCalendar parsed string
fixOverflow()method 
protected static function fixOverflow(str:String):String

iCalendar spec expects lines no longer than 75 characters. This method will fold overflow by adding a CRLF and a single whitespace.

Parameters

str:String — the string to process

Returns
String — the formatted string
getDayNum()method 
protected static function getDayNum(dayStr:String):int

Converts a iCalendar string representation of a day of the week into an actionscript numerical representation of the day of a week.

Parameters

dayStr:String — the int representation of a day of the week ("SU" = 0)

Returns
int — the String representation
getDayString()method 
protected static function getDayString(dayNum:int):String

Converts an actionscript numerical representation of a day of the week into an iCalendar string representation of the day of a week.

Parameters

dayNum:int — the int representation of a day of the week (0 = sunday)

Returns
String — the String representation
getDecodedDate()method 
protected static function getDecodedDate(str:String, timeZones:Array = null):Date

Decodes iCalendar formatted DATE or DATE-TIME values into as3 Dates.

If time is defined as a specific timezone, and the timezone wasn't defined in the string, the time zone the flash player is running in will be assumed.

Parameters

str:String — the String to decode
 
timeZones:Array (default = null)

Returns
Date — the decoded Date
getICalendarDateStamp()method 
protected static function getICalendarDateStamp(date:Date):String

Converts a Date object to an iCalendar formatted string for "floating time", E.G. a "date=value" timestring. This is an allDay event so use local time definitions.

Parameters

date:Date — the Date object to convert

Returns
String — a iCalendar encoded string
getICalendarTimeStamp()method 
protected static function getICalendarTimeStamp(date:Date):String

Converts a Date object to an iCalendar formatted timestamp string. Not allDay

Parameters

date:Date — the Date object to convert

Returns
String — a iCalendar encoded string
getOccurrenceDay()method 
protected static function getOccurrenceDay(year:int, month:int, day:int, interval:int):int

Get the day.

Parameters

year:int
 
month:int
 
day:int
 
interval:int

Returns
int — int
importICalendar()method 
public static function importICalendar(data:String):iCalendarData

Accepts an iCalendar formatted string and returns a iCalendarData object.

Minimal error checking. String should strictly comply with the iCalendar spec.

Parameters

data:String — a String of the iCalendar feed.

Returns
iCalendarData — iCalendarData object
readVEventProperty()method 
protected static function readVEventProperty(newSchedulingData:SchedulingData, line:String, timeZones:Array):void

Decodes a property line contained within a VEVENT and updates the passed SchedulingData object.

Parameters

newSchedulingData:SchedulingData — the SchedulingData object being constructed
 
line:String — the text line to decode
 
timeZones:Array — an array of defined time zones

unfoldAndEscape()method 
protected static function unfoldAndEscape(str:String):String

Unfolds string by removing > 75 char line breaks and unescapes commas, colons, and semi-colons.

Parameters

str:String — the string to process

Returns
String — processed string