I was trying to make an iCalendar file for all platform, one event in the file is a recurrence pattern which specifies the 9th work day every month, like the following content:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Test//Calendar//EN
X-PUBLISHED-TTL:PT1H
X-WR-CALNAME:TestCalendar
BEGIN:VEVENT
UID:Test
DTSTART:20160101
DURATION:PT1D
RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=9
SUMMARY:The 9th work day.
DESCRIPTION:This is the 9th day.
END:VEVENT
END:VCALENDAR
This event works fine both on iOS calendar and google calendar, but not work on Outlook calendar.
I've found this link which says that outlook calendar only supports BYSETPOS between -1 to 4, sadly this is almost being confirmed by my own experiment.
So I wonder if anyone has the same problem when importing your iCalendar file to Outlook, or is there any workaround to solve the BYSETPOS issue?
I made a workaround yesterday.
Since my iCalendar file is being created by a RESTFul call hosted by .NET Web Api, and I have different kinds of RRULE to generate, in order to keep this case in the same design, I choose to generate this RRULE according to DateTime.Now and re-generate it for every call:
private int GetTheWorkDay(int parameterX)
=> this.GetDaysInMonth()
.Where(d => d.DayOfWeek != DayOfWeek.Saturday &&
d.DayOfWeek != DayOfWeek.Sunday)
.OrderBy(d => d)
.ToArray()[parameterX - 1]
.Day
public string ParseSetting(int parameterX)
=> $"FREQ=MONTHLY;BYMONTHDAY={this.GetTheWorkDay(parameterX)}";
Related
I am using ruby koala facebook graph API gem to retrieve events but cant restrict the events using a date range. I seem to be getting all events (even ones which have happened). What I am trying to do is get events is the next 200 days. I am using the following (ruby) code:
Koala.config.api_version = 'v2.10'
oauth = Koala::Facebook::OAuth.new app_id, app_secret
graph = Koala::Facebook::API.new oauth.get_app_access_token
from_date = Date.today
to_date = from_date + 200
fb_events = graph.get_object( fb_venue["url_listings"] + "?time_range={\"since\":#{from_date}, \"until\":#{to_date}" )
I am then getting the events 25 at once (the facebook default limit) using 'fb_events.next_page' to get them all.
I seem to get getting all events, including ones is the past.
Are you sure that the #get_object method wants a query string like that? Based on the docs[1], it seems that you should pass your object ID (which I assume is in fb_venue['url_listings'] for you as a first arg, and then metadata in a subsequent arg as a Hash. So I'd try something like:
fb_events = graph.get_object(fb_venue['url_listings'],
{since: from_date, until: to_date})
...according to the key/nesting structure FB expects.
Edit: forgot link to docs.
[1] -
http://www.rubydoc.info/github/arsduo/koala/Koala%2FFacebook%2FGraphAPIMethods%3Aget_object
According to the doc I don't think that you can request all the events, You can only select an event by using /{event-id} like this example or you can get user's events but you will need to ask him for the permission according to
permissions.
add user_events to the list of scope that you are permitting from user.
By this when user sign up using Facebook to your application it will take a permission for his events.
After that by using graph.get_object({facebook-user-id} + '/events') you will get 25 of his events as a default value and you can add {limit: 5} as a second parameter to the get_object function, You can use until and since but they should be in A Unix timestamp look at this to see the needed date format, hope this would help.
i dont understand a sence of SendInvitationsMode.SendToNone.
Msdn.microsoft.com shows, how appointment could be created with this
option:
https://msdn.microsoft.com/en-us/library/office/dd633661(v=exchg.80).aspx
But when i am not using this option and set only start- and end-date to the same date (for example 2016-12-12) and save like this:
appointment.save();
, i expect, that outlook shows me in my calender this appointment only on the date: 2016-12-12.
But outlook shows me some different days. Obviously start- and end-date will be ignored, when i'am not set this option, when i save appointment: SendInvitationsMode.SendToNone.
"SendToNone" means for me, that this appointment will not be send to something else.
SendToNone means if you have a Meeting that when you create the meeting appointment meeting invitations will not be sent when you call save.
But when i am not using this option and set only start- and end-date to the same date (for example 2016-12-12) and save like this:
What are you trying to achieve though? are you trying to create an All Day appointment ? https://msdn.microsoft.com/en-us/library/office/dn756538(v=exchg.150).aspx the thing to be careful of here is matching the timezone if you have users in different timezone.
I'm learning Rails while coding my first app. My app has an apppointment model, which is a join table with the following columns (and datatypes): date (date), starts_at (time), and ends_at (time). I'm trying to write a method for a custom validation to prevent users from inadvertantly scheduling SAME day appointments for starts_at times that are in the past. In other words, the starts_at time for a same day appointment must always be greater than the current time of day.
For example: Say today is Monday, Jan. 12, 2015, and the current time is 12:00 pm. I need the model validation to prevent a user from scheduling an appointment for today at say 6:30 am, because that time is already past (per the server's time zone).
Here's my unsuccessful attempt at writing a custom validation & method to accomplish the objective:
validate :past_time_appointment
private
def past_time_appointment
if self.date == Date.current && self.starts_at < Time.now
errors.add(:starts_at, "can't be in the past")
end
end
This code doesn't work properly. While researching the issue, I found another Stackoverflow post which addressed the problem, but it was not a Rails project. It was related to an ASP.NET MVC 1 application in C#.
What's the best way to approach this problem in Rails 4? My code doesn't work, but I'm not sure why. I'd appreciate any advice and help!
I solved the problem after thinking about it anew. I discarded my previous method and wrote a new one:
private
def today_appointment
self.date == Date.current
end
then I used the Validates_Timeliness gem ( https://github.com/adzap/validates_timeliness ) to call the method:
validates_time :starts_at, :after => :now, :if => :today_appointment
Placing the validation in my Appointment model prevents a user from saving a same day appointment which has a "starts_at" time in the past. The ":if" statement in the validation "scopes" it to the current day only. This is to prevent the validation from blocking appointments on other days. This approach accomplishes my objective. I hope this helps someone else who face this problem in the future.
I was hoping that the appcast pubDate xml element would allow me to specify that my app cannot be considered for update unless the current date is the publish date (pubDate) or later.
Here's a sample appcast that includes the pubDate element inside the item element:
<item>
<title>Version 2.0 (2 bugs fixed; 3 new features)</title>
<sparkle:releaseNotesLink>http://you.com/app/2.0.html</sparkle:releaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your Great App 2.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
</item>
which was copied from Sparkle's site here: https://github.com/sparkle-project/Sparkle/blob/0ed83cf9f2eeb425d4fdd141c01a29d843970c20/Sample%20Appcast.xml
So the sequence is this:
I copy my updated app--myapp v1.1--to my update web server on Monday
on my update server, I also set the pubDate to Wednesday (in the proper RFC 822 format)
on Tuesday, someone runs myapp v1.0 and tries to update myapp to whatever is available using sparkle appcast bundled inside myapp v1.0
at that point, sparkle compares the version and sees that an update should happen, but its still only Tuesday so sparkle doesn't give the option to update until he tries again on Wednesday (or later)
Wednesday arrives and user attempts to update myapp v1.0 again and this time it works because version is updatable and date is wednesday.
Is that the purpose of the pubDate Sparkle element?
Does Sparkle use the pubDate to help determine whether an update should happen or not in addition to the version number?
Holding an app back from updating until some date is what I want, but I'm finding that pubDate doesn't seem to do that for me.
I couldn't find reference to the purpose of the pubDate in Sparkle docs: https://github.com/sparkle-project/Sparkle/wiki
Sparkle uses RSS, as you know, to list application updates inside enclosure tags (this is what they call "appcasting" - see: http://connectedflow.com/appcasting/)
The pubDate element is not specific to Sparkle - it's just a part of the RSS spec (see http://www.w3schools.com/rss/rss_tag_pubdate.asp ), and may/should be used by generic rss readers to present items/entries chronologically.
By itself, Sparkle does only one thing with pubDate as far as I can tell - and it's ordering update candidates (https://github.com/sparkle-project/Sparkle/blob/master/SUAppcast.m#L218)
Now, you can further customize the way Sparkle selects eligible updates by subclassing SUUpdater: see https://github.com/sparkle-project/Sparkle/wiki/bundles#wiki-subclassing-suupdater and especially the bestValidUpdateInAppcast method: https://github.com/sparkle-project/Sparkle/wiki/customization
There, you should be able to further process items and achieve the behavior you have in mind.
I am trying to get a facebook fql query to work using the browser, I have a valid oauth token (I can make graph api calls with it).
Here is the url I tried:
https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=89192912655 AND end_time=1280430050 AND period=86400 AND metric='page_fans'&access_token=?
I also tried running the fql query through a sql encoder first:
https://api.facebook.com/method/fql.query?query=SELECT%20metric%2C%20value%20FROM%20insights%20WHERE%20object_id%3D89192912655%20AND%20end_time%3D1280430050%20AND%20period%3D86400%20AND%20metric%3D'page_fans'&access_token=?
I tried a few other metrics, I can get the metrics via the graph api as well, so I know they are there.
Im sure im doing something dumb, but I have been stumped on this for a while now! Every call just returns this:
<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true"/>
Maybe my dates are a problem, I used this to get the date: (ruby)
t = Time.now
=> Tue Aug 03 15:00:50 -0400 2010
>> t = t - 5.days
=> Thu Jul 29 15:00:50 -0400 2010
>> t.to_i
=> 1280430050
any ideas?
We have confirmed this bug. This is due to the end_time having to be aligned with day delimiters in PST in order for the Insights table to return any data. To address this issue, we introduced two custom functions you can use to query the insights table:
end_time_date() : accept DATE in string form(e.g. '2010-08-01')
period() : accept 'lifetime', 'day', 'week' and 'month'
For example, you can now query the insights table using:
SELECT metric, value FROM insights
WHERE object_id = YOUR_APP_ID AND
metric = 'application_active_users' AND
end_time = end_time_date('2010-09-01') AND
period = period('day');
We will document about these functions soon, sorry for all the inconvenience!
P.S. If you don't want to use the end_time_date() function, please make sure the end_time timestamp in your query is aligned with day delimiters in PST.
Thanks!
Facebook Insights Team
The response you're seeing is an empty response which doesn't necessarily mean there's no metric data available. A few ideas what might cause this:
Are you using a user access token? If yes, does the user own the page? Is the 'read_insights' extended permission granted for the user / access token? How about 'offline_access'?
end_time needs should be specified as midnight, Pacific Time.
Valid periods are 86400, 604800, 2592000 (day, week, month)
Does querying 'page_fan_adds' metric yield meaningful results for a given period?
While I haven't worked with the insights table, working with Facebook's FQL taught me not to expect error messages, error codes but try to follow the documentation (if available) and then experiment with it...
As for the date, use the following ruby snippet for midnight, today:
Date.new(2010,9,14).to_time.to_i
I also found the following on the Graph API documentation page:
Impersonation
You can impersonate pages administrated by your users by requesting the "manage_pages" extended permission.
Once a user has granted your application the "manage_pages" permission, the "accounts" connection will yield an additional access_token property for every page administrated by the current user. These access_tokens can be used to make calls on behalf of a page. The permissions granted by a user to your application will now also be applicable to their pages. (source)
Have you tried requesting this permission and use &metadata=1 in a Graph API query to get the access token for each account?
If you want to know the number of fans a facebook page has, use something like:
https://graph.facebook.com/cocacola
The response contains a fan_count property.
I'm not sure the date is correct. do you really want the date as an integer?
Usually SQL takes dates in db-format, so to format it you'd use:
Date.new(2010,9,14).to_s(:db)
(Time.now - 5.days).to_s(:db)
# or even better:
5.days.ago.to_s(:db)
If, like me, you came here after getting this from another FQL statement, then your problem is not including the access_token parameter, e.g.
https://api.facebook.com/method/fql.query?query=SELECT+name+FROM+user+WHERE+uid+%3D+me()&access_token=...
(You can use fb.getAccessToken())