Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

CLC-415 - Campus Events date off by one #236

Merged
merged 1 commit into from

2 participants

This page is out of date. Refresh to see the latest.
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/main/webapp/widgets/campusevents/javascript/campusevents.js
View
14 src/main/webapp/widgets/campusevents/javascript/campusevents.js
@@ -28,14 +28,18 @@ calcentral.Widgets.campusevents = function(tuid) {
$.each(data.item, function(index, value){
// Campus events feed does not include a date property; appends date as URL param instead
- var urldate = calcentral.Api.Util.parseURI({'url':value.link}).queryKey.date;
- var eventDate = new Date(urldate);
+ var urldate = calcentral.Api.Util.parseURI({
+ 'url': value.link
+ }).queryKey.date.split('-');
+
+ var eventDate = new Date();
+ eventDate.setFullYear(urldate[0], parseInt(urldate[1], 10) - 1, urldate[2]);
// #todo Another reason we need a good JS date lib
var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var shortDay = weekdays[eventDate.getDay()];
- var theMonth = eventDate.getMonth() + 1;
- data.item[index].friendlyDate = shortDay + ' ' + theMonth + '/' + eventDate.getDate();
+ var theMonth = parseInt(urldate[1], 10);
+ data.item[index].friendlyDate = shortDay + ' ' + theMonth + '/' + parseInt(urldate[2], 10);
});
return data;
};
@@ -59,7 +63,7 @@ calcentral.Widgets.campusevents = function(tuid) {
var getFeed = $.Deferred();
$.ajax({
'dataType': 'json',
- 'url': 'http://query.yahooapis.com/v1/public/yql?q=select%20title%2C%20link%20from%20rss%20where%20url%3D%22http%3A%2F%2Fevents.berkeley.edu%2Findex.php%2Frss%2Fsn%2Fpubaff%2Ftype%2Fday%2Ftab%2Fall_events.html%22%20limit%204&format=json&callback=',
+ 'url': '//query.yahooapis.com/v1/public/yql?q=select%20title%2C%20link%20from%20rss%20where%20url%3D%22http%3A%2F%2Fevents.berkeley.edu%2Findex.php%2Frss%2Fsn%2Fpubaff%2Ftype%2Fday%2Ftab%2Fall_events.html%22%20limit%204&format=json&callback=',
'success': getFeed.resolve,
'error': function() {
getFeed.resolve({});
Something went wrong with that request. Please try again.