Parsing iCal from Outlook: how do I tell what the recurrence schedule is for this event? - outlook

I'm using Python, but I don't think that's relevant here. The iCal snippet below is from an Outlook 2010 export (full data). In Outlook, the event shows up as recurring, including an instance of the event on April 12th, 2012. If you open the series, it says
recurrence: Occurs every Thursday effective 3/29/2012 from 12:00 PM to 12:30 PM
My question is: is it possible to derive the recurrence schedule from the information below? Which fields will give me the information? I would expect to find an RRULE, but there's no such thing here.
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20120312T133301Z
DESCRIPTION:\n
DTEND;TZID="Eastern Standard Time":20120329T123000
DTSTAMP:20120411T220938Z
DTSTART;TZID="Eastern Standard Time":20120329T120000
LAST-MODIFIED:20120531T155022Z
LOCATION:1501 Fake Street\, Conference Room G
PRIORITY:5
RECURRENCE-ID;TZID="Eastern Standard Time":20120419T120000
SEQUENCE:8
SUMMARY;LANGUAGE=en-us:My Cool Event
TRANSP:OPAQUE
UID:040000008200E00074C5B7101A82E008000000000029934B3300CD01000000000000000
0100000001516438BA45C3946AF9C4C2A563FB2BE
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve
rsion 14.02.5004.000">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted f
rom text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG
="en-us"></SPAN></P>\n\n</BODY>\n</HTML>
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-APPTLASTSEQUENCE:16
X-MS-OLK-APPTSEQTIME:20120411T220937Z
X-MS-OLK-AUTOFILLLOCATION:FALSE
X-MS-OLK-CONFTYPE:0
END:VEVENT

I ran through your ICS file with following program:
from icalendar import Calendar, Event
from datetime import datetime
cal = open('test.ics','rb')
ical = Calendar.from_ical(cal.read())
for component in ical.walk():
if component.name == 'VEVENT':
for item in component.sorted_items():
if item[0] == 'RECURRENCE-ID':
reoccur_item = item[1]
print reoccur_item.params
print reoccur_item.dt
continue
if item[0] == 'DTSTART':
print 'DSTART', item[1].dt
continue
if item[0] == 'DTEND':
print 'DTEND', item[1].dt
continue
if item[0] == 'DTSTAMP':
print 'DTSTAMP', item[1].dt
continue
print item
cal.close()
And following is the output that I obtained
('SUMMARY', vText(u'My Cool Event'))
DSTART 2012-03-29 12:00:00
DTEND 2012-03-29 12:30:00
DTSTAMP 2012-04-11 22:09:38+00:00
('UID', vText(u'040000008200E00074C5B7101A82E008000000000029934B3300CD01000000000000000 0100000001516438BA45C3946AF9C4C2A563FB2BE'))
RECURRENCE-ID Parameters({'TZID': 'Eastern Standard Time'})
RECURRENCE-ID 2012-04-19 12:00:00
('SEQUENCE', 8)
('CLASS', vText(u'PUBLIC'))
('CREATED', <icalendar.prop.vDDDTypes instance at 0x101c4e518>)
('DESCRIPTION', vText(u'\n'))
('LAST-MODIFIED', <icalendar.prop.vDDDTypes instance at 0x1020874d0>)
('LOCATION', vText(u'1501 Fake Street, Conference Room G'))
('PRIORITY', 5)
('TRANSP', vText(u'OPAQUE'))
('X-ALT-DESC', vText(u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve rsion 14.02.5004.000">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted f rom text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG ="en-us"></SPAN></P>\n\n</BODY>\n</HTML>'))
('X-MICROSOFT-CDO-BUSYSTATUS', vText(u'BUSY'))
('X-MICROSOFT-CDO-IMPORTANCE', vText(u'1'))
('X-MICROSOFT-DISALLOW-COUNTER', vText(u'FALSE'))
('X-MS-OLK-APPTLASTSEQUENCE', vText(u'16'))
('X-MS-OLK-APPTSEQTIME', vText(u'20120411T220937Z'))
('X-MS-OLK-AUTOFILLLOCATION', vText(u'FALSE'))
('X-MS-OLK-CONFTYPE', vText(u'0'))
The re-occurrence rule is empty and this almost looks like single instance of the re-occuring event but for the various Microsoft specific data in the end. This has sequence number 8 and X-MS-OLK-APPTLASTSEQUENCE:16 suggests that the last instance should have sequence 16.
It almost looks like it has created multiple instances with sequence stamp on each of team with the same UID

did you try exporting the calendar using vba? this might be an option for you to get the rrule. you would have to watch for Item.GetRecurrencePattern (Item being declared as myItem As AppointmentItem) and compare to olRecursMonthly, olRecursYearly, ... then look for the interval and count attributes of your item to rebuild the whole rrule string.
you can find more details at this project: http://sourceforge.net/projects/outlook2ical/files/outlook2ical/v1.04/

Related

What is the timezone of publishedAt in Snippet of Youtube API response?

Editing to include the API response too.
Request to API
base = 'https://www.googleapis.com/youtube/v3/videos'
params = {
'part' : 'snippet,contentDetails',
'id': <List of Video IDs>,
'key':gkey
}
response = requests.get(base, params).json()
Sample Snippet
{'publishedAt': ***'2017-11-13T06:06:22Z'***,
'channelId': 'UCDYetMc6gOLkhIiNzFyrJPA',
'title': 'Capítulo 12 | MasterChef 2017',
What is the TIMEZONE of the response['items'][0]['snippet']['publishedAt'] ?
I have searched the entire documentation here
but couldn't find this CRITICAL info.
Thanks in advance!!
As per the docs, any video's publishedAt property is given in ISO 8601 format:
snippet.publishedAt (datetime)
The date and time that the video was published. [...]
The value is specified in ISO 8601 format.
Looking further into the referenced ISO doc, it can be read that the designator Z means UTC time zone:
Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator ("Z").

How to use #datetime function in telegram instant view?

I am trying to set up a telegram Instant View. I am facing problem with the function datetime #datetime, I've looked at the official documentation.
I have the following date Jul 19, 2018 at 2:25pm. In case we are on the same year of the date, the string won't contain the year ex: Jul 19 at 2:25pm means 19 July of this year. How can I deal with the missing year?
This is my code so far.
#datetime(-2, "en-US", "LLL d 'at' k:mm"): "Jan 25 at 2:44pm"
published_date: $#
#manage the current year case
#datetime(0, "en-US", "LLL d, YYYY 'at' k:mma"): "Jan 25, 2018 at 2:44pm"
published_date: $#
As of now the missing year is not properly managed. In this way the year is always 1970.
The algorithm is following:
Try to parse the date with YYYY inside
If failing, the $pubslished_date will contain 0 or some garbage (try to #debug it). So you can use something like #if_not( $published_date ) { ... }, where you can try to parse the date without YYYY. Don't forget to force redefine the variable with published_date!: ….
If that won't work, try to play with conditional binding: pubslihed_date?: …. It has the same logic. (Just to put a question mark ? in the second binding in your current code).

Is event in specified date in Apple calendar by AppleScript?

I need to test if in specified day has any events in the built-in Apple Calendar app. Here is my current idea as pseudocode:
// input variables
day_to_test = 23
month_to_test = 8
year_to_test = 2016
testing_date = day_to_test + month_to_test + year_to_test as date
// actual "code"
if testing_date has any event in Apple calendar Then
display dialog "There is any event on that day!"
else
display dialog "Free of events!"
end if
Try:
tell application "Calendar"
tell calendar "Main" -- national holiday calendar in my iCloud
set today to current date
set today's year to 2013
set today's month to 3
set today's day to 5
set today's time to 0
copy (today + days) to tomorrow
set currentEvents to events whose start date ≥ today and end date ≤ tomorrow
end tell
end tell

How can I make time ranges for an iCal calendar from a database of entries?

I've got some Perl script that I'm using to scrape calendar events. I've got a database of events, and now I'd like to process these into an iCal file. I opened my university's academic iCal calendar and got the following:
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
X-WR-TIMEZONE;VALUE=TEXT:America/Los_Angeles
PRODID:-//MMISoftware\, //MMISoftware//EN
X-WR-CALNAME;VALUE=TEXT:spring14cal
X-WR-RELCALID;VALUE=TEXT:87FB4C57-1D7B-4B80-B200-AEED845CB3AF
VERSION:2.0
BEGIN:VEVENT
SEQUENCE:1
UID:41D26C6E-965B-4BFB-AEC0-F1614074A4AF
DTSTAMP:20140127T111052Z
DTSTART;VALUE=DATE:20140101
SUMMARY:FAFSA
DESCRIPTION:First day to obtain FAFSA financial aid applications for 201
4-15 academic year online at http://www.fafsa.ed.gov
DURATION:P1D
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
UID:DFE257FB-F475-43C2-9AEB-569EC4BA321D
DTSTAMP:20140127T111052Z
DTSTART;VALUE=DATE:20140106
SUMMARY:CA Dream
DESCRIPTION:First day to obtain California Dream Act financial aid appli
cations for 2014-15 academic year online at https://dream.csac.ca.gov
.
.
.
.
I see a start date, end date, and a time stamp, but I don't see a range... Not sure how to use my existing database to make an iCal file---you know, metaprogramming---with time ranges like the following:
http://musformation.com/pics/thg_sync_apple_ical.jpg
You could use Date::ICal to format the duration strings.
The duration itself ( in your case we can see only the duration of the first event, because the duration of the second event would be the first line you skipped ) is DURATION:P1D, where P1D is the Duration itself and DURATION is the property name.
Further information about ICals Duration can be found here.
When you want to parse ICal files, you can use ICal::Parser.
Creating ICal Files can be done easily with Data::ICal. An example:
use Data::ICal;
use Data::ICal::Entry::Event;
use strict;
use warnings;
my $calendar = Data::ICal->new;
my $vtodo = Data::ICal::Entry::Event->new;
$vtodo->add_properties(
summary => "read SO",
description => "reading cool SO posts",
dtstart => Date::ICal->new(
day => 4,
month => 6,
year => 2014,
hour => 8,
min => 30,
sec => 00
)->ical,
dtend => Date::ICal->new(
day => 5,
month => 6,
year => 2014,
hour => 9,
min => 50,
sec => 00
)->ical,
);
$calendar->add_entry($vtodo);
print $calendar->as_string;

Business date/holiday handling

I've posted this question for C# but I may be working in Ruby instead. So I'm asking the same question about Ruby:
I'm looking for a Ruby class/library/module that works similarly to the Perl module Date::Manip as far as business/holiday dates. Using that module in Perl, I can pass it a date and find out whether it's a business day (ie, Mon-Fri) or a holiday. Holidays are very simple to define in a config file (see Date::Manip::Holidays). You can enter a 'fixed' date that applies to every year like:
12/25 = Christmas
or 'dynamic' dates for every year like:
last Monday in May = Memorial Day
or 'fixed' dates for a given year like:
5/22/2010 = Bob's Wedding
You can also pass in a date and get back the next/previous business day (which is any day that's not a weekend and not a holiday).
Does anyone know of anything like that in the Ruby world?
You may use the holidays-gem.
http://rubygems.org/gems/holidays
Some national (and regional) holidays are already predefined, you may define your own holiday definitions.
The business_time gem should do what you need.
The example at bottom of the README doc is a good starting example:
require 'rubygems'
require 'active_support'
require 'business_time'
# We can adjust the start and end time of our business hours
BusinessTime::Config.beginning_of_workday = "8:30 am"
BusinessTime::Config.end_of_workday = "5:30 pm"
# and we can add holidays that don't count as business days
# July 5 in 2010 is a monday that the U.S. takes off because
# our independence day falls on that Sunday.
three_day_weekend = Date.parse("July 5th, 2010")
BusinessTime::Config.holidays << three_day_weekend
friday_afternoon = Time.parse("July 2nd, 2010, 4:50 pm")
tuesday_morning = 1.business_hour.after(friday_afternoon)
You probably going to need the chronic gem to help you build the holiday dates from your config file. However YMMV because your example last monday in may doesn't work in chronic. Hackaround is do something like this:
# last monday in May (2010)
Chronic.parse('last monday', :now => Time.parse('2010-06-01'))
And look at the tickle gem which works on top of chronic for a way to add recurring events.
/I3az/
You could take a look at my Workpattern gem. It allows you to specify working and resting times. It was aimed at producing a "Calendar" like is used in planning tools such as Microsoft Project and Primavera P6, so you can specify right down to the minute.
Here is a simple example:
Create a new Workpattern mywp=Workpattern.new('My Workpattern',2011,10) This is for 10 years from 2011 but you can make it longer or shorter.
Tell it you want the Weekends to be resting and that you also want to rest during the week so you work between 9 and 12 in the morning and 1 and 6 in the afternoon.
mywp.resting(:days => :weekend)
mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(0,0),:to_time=>Workpattern.clock(8,59))
mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(12,0),:to_time=>Workpattern.clock(12,59))
mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(18,0),:to_time=>Workpattern.clock(23,59))
Now just calculate using minutes
mydate=DateTime.civil(2011,9,1,9,0)
result_date = mywp.calc(mydate,1920) # => 6/9/11#18:00
1920 is 4 days * 8 hours a day * 60 minutes and hour.
I wrote the gem to learn Ruby - only scratched the surface.
Check out the biz gem.
Here's an example configuration:
require 'biz'
Biz.configure do |config|
config.hours = {
mon: {'09:00' => '17:00'},
tue: {'00:00' => '24:00'},
wed: {'09:00' => '17:00'},
thu: {'09:00' => '12:00', '13:00' => '17:00'},
sat: {'10:00' => '14:00'}
}
config.holidays = [Date.new(2014, 1, 1), Date.new(2014, 12, 25)]
config.time_zone = 'America/Los_Angeles'
end
When you use the optional core extensions, it's as easy as the following to find out if a date is a business day:
require 'biz/core_ext'
Date.new(2014, 12, 25).business_day? # => false

Resources