later.js every nth weekday of every month - recurring-events

I am using later.js (meteor package, voidale:later-js-tz#1.1.9) to schedule events, using the later.parse.text() parser.
I can schedule weekly events on a given weekday with no problem, with strings like 'at 11:00 on Monday'.
But I get parse errors trying things like 'at 11:00 on every second Monday of every month'.
Q: Is there a way to do this in later.js, or if not, is there a javascript library available that does support this?
Thanks.

I found moment-recur, which supports this nth-weekday of a month in its API, but doesn't have a text parser.
I then used PEGjs to build a text parser which outputs the necessary parameters, which I use in a straightforward way to call the moment-recur API.

Related

Fetch all events for the next 24 hours, including current events in the Office365 API

I'm using the following API call to fetch all events for the next 24h. The thing is, this doesn't return events that are currently active. Lets say an event started on 2018-08-01T13:00:00.000Z, this event isn't returned.
https://graph.microsoft.com/v1.0/users/me/calendars/<KEY>=/calendarView?startDateTime=2018-08-01T13:17:29.233Z&endDateTime=2018-08-02T13:17:29.233Z&orderby=start/dateTime&top=5
Now I know I can decrease the startTime to some hours before the current date/time and manually filter out all the old items except current ones, but what If an event takes a day, multiple days or a week? I would like Office365 to only return the items I need, so that is including the currently active items.
I can't find anything in the Office365 API documentation that points me in the right direction nor something that could lead to a workaround. Does anyone know how to fetch the current events as well but using the current date/time as "start date"?
https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/calendar-rest-operations
https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/complex-types-for-mail-contacts-calendar#event
I found out how to do is with some help from Microsoft. I now use https://graph.microsoft.com/v1.0/users/me/calendars//events with a $filter property containing the following:
Start/DateTime le '<current date/time>' and End/DateTime gt '<current date/time>' or Start/DateTime gt '<current date/time>'
This returns current events as well as future events.

Eventfinder API: start_date parameter doesn't work

I am trying to get results from the Eventfinder API. It's a REST based service.
I want to get events from tomorrow.
But instead I will always get events from today (probably because default time is now).
Let's assume we have Friday the 2014-03-28 and I want events of Saturday the 2014-03-29.
When I request this url:
http://api.eventfinder.co.nz/v2/events.xml?rows=1&start_date=2014-03-29 I am getting events of the 2014-03-28.
For me it's not clear how to set the time, after I read the documentation on Eventfinder.co.nz
Now I have found a solution by myself.
It's important setting the end_date parameter too. If the end_date is not set, the event must happen at the current date AND a the date where the start_date is set.
This is an example usage, getting events of Saturday the 2014-03-29.
http://api.eventfinder.co.nz/v2/events.xml?rows=1&start_date=2014-03-29&end_date=2014-03-30

Selecting a datetime range in YII input form

Here is the problem.
I have to create a submission form on my Yii-based website. The form requires to enter a datetime range.For that I am using "jui datetimepicker" third-party Yii extension.
http://www.yiiframework.com/extension/datetimepicker/
I use two date fields with this extension pertaining to start and end time respectively. So, what I want to achieve is be able to restrict the start datetime only to time in the future (neither past dates nor time should be selected) and the end time itself should be restricted to the maximum of three hours following the start time.
EXAMPLE: a user wants to schedule an event. They choose a date and time, which are of course in the future. Let's say they choose March 15, 13 O'clock as the start time in the start time field. Once they are done and move to the next field ("end time"), the respective datetimepicker restricts the range of time from March 15, 13:00 to March 15, 16:00.
Hence the second datetimepicker should be dynamically updated depending on the input of the first one.
It's possible o specify date range in the datetimepicker starting from the current date, but there is nothing like that for the time selection, so a user still can select time which has already passed.
It's not that I want to solve this problem with this extention, if anybody has any suggestions about YII solutions allowing to specify a datetime range in the most clean and effective way - it would be much appreciated.
You should use the edaterangepicker extension instead.
Given the API for the jquery timepicker addon. you should add the following to your widget call (along side 'model','attribute', etc)
'options'=>array(
'minDateTime'=>'<start dateTime here>',
'onSelect'=>'<JS function to run>'
)
The function you run on the "onSelect" event should dynamically set the minDateTime for the second dateTime input field, for ex:
function (selectedDateTime){
<EndDatePickerElement>.datetimepicker('option', 'minDateTime', <start dateTime here using selectedDateTime> );
}
There are more examples on the link provided earlier if you need to make it even more precise (like say if you wanted the starting date to be pushed back by the amount of time the user was on the page rather than it being set when the page was loaded. etc...)

Sharethis api top shared urls

I'm working on building a block on my site that contains the top 5 most shared urls on my domain via the sharethis api, I've been testing it and have gotten some unexpected results...
when I check the domain statistics api, I get the expected results:
request:
http://rest.sharethis.com/analytics/V2/getDomainStats.php?domain={my-domain}&pub_key={my-publisher-key}&access_key={my-secret-key}
response:
{"status":"SUCCESS","from_date":"20120620","to_date":"20120627","data":
{"domain_summary":[{"clicks":1092,"shares":134,"traffic":1393,"date":"06\/20","channel_stats":
[{"shares":86,"clicks":404,"traffic":412,"channel":"facebook"},
{"shares":25,"clicks":617,"traffic":898,"channel":"email"},
{"shares":12,"clicks":0,"traffic":0,"channel":"fblike"},
{"shares":7,"clicks":42,"traffic":31,"channel":"twitter"},
{"shares":3,"clicks":0,"traffic":0,"channel":"plusone"},
{"shares":1,"clicks":0,"traffic":0,"channel":"pinterest"},
{"shares":0,"clicks":17,"traffic":19,"channel":"blogger"},
{"shares":0,"clicks":12,"traffic":33,"channel":"google_bmarks"}]}.....
I've truncated those results obviously since they go back for a week...
when I try to find out what urls are the most active from my domain:
request:
http://rest.sharethis.com/analytics/V2/getTopUrlStats.php?domain={my-domain}&from_date=2012-06-27&to_date=2012-01-01&pub_key={my-publisher-key}&access_key={my-secret-key}
response:
{"status":"SUCCESS","from_date":"20120627","to_date":"20120101","last_batch_date":"20120626","data":{"top_urls_summary":[]},"today":""}
Obviously this is not what I'm looking for, I have the clicks and on the sharethis site I can go to my metrics and view the info I'm looking for with no problem, but the api is not answering with any data. I have tried changing the date range or omitting it completely (which for some reason returns an empty data set) to no avail. Has anyone else run into a similar problem?
Ok Sharethis support finally got back to me about the problem:
According to sharethis api :
To Date End date for data. Note: date must be in yyyy-mm-dd format. Default is 7 days ago.
From Date Start date for data. Note: date must be in yyyy-mm-dd format. Default is 'today'.
These are backwards, that's 1 reason why my call wasn't working, "To date" should be the more recent date when defining the date range... the "defaults" don't work so you must enter both values, and when you enter todays date as the "To Date" it may return "collection failed", so best to start with yesterday

How to change Unix Timestamp to Human Date in rails 3

I've seen a couple of posts doing the reverse for mysql, but I'm looking for a way to change a unix timestamp to a human readable date (ideally one I can change the format of) and I haven't been able to find anything so far.
I'm storing a date pulled from an XML feed, via NokoGiri (in Rails 3.1.1) as part of a hash:
'date' => i.xpath('#unix-timestamp')
which gets the number fine, but how the devil do you make this DD-MM-YYYY to be put in one of my views?
I've tried Time.at( (i.xpath('#unix-timestamp') ) to no avail; I just get the error 'can't convert Nokogiri::XML::NodeSet into an exact number' and now I've hit a wall
Much gratitude for any help!
Time.at is definitely a call that should work to convert from epoch time to a ruby Time object (see here for an example). So it seems like you need to work on converting your XML result into something more usable. I think you want to try using NodeSet#text to get a string output, then converting that to an integer:
Time.at(i.xpath('#unix-timestamp').text.to_i)
There's a decent but basic tutorial for NokoGiri in the Engineyard blog
You can use like : DateTime.strptime("1373210218",'%s')
and also Time.at(1373210218).strftime("%B %e, %Y at %I:%M %p")