Skip to content

Commit

Permalink
api: removed depencency on util.js (that was silly)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbaert committed Nov 26, 2010
1 parent 6e03cce commit 33a5751
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions js/irail-api.js
Expand Up @@ -74,6 +74,17 @@ var IRail = (function(){

return data;
};

var t = function(time, format) {
switch (format) {
case 'ddmmyy':
return _.padZeroes(time.getDate())+_.padZeroes(time.getMonth()+1)+(time.getYear()%100);
break;
case 'mmhh':
return _.padZeroes(time.getHours())+_.padZeroes(time.getMinutes());
break;
}
};

return {
// IRail.stations()
Expand Down Expand Up @@ -114,8 +125,8 @@ var IRail = (function(){
var uri = baseUri+'/connections/?format=json'+
'&from='+encodeURIComponent(args['departure'])+
'&to='+encodeURIComponent(args['arrival'])+
'&date='+_.t(date, 'ddmmyy')+
'&time='+_.t(date, 'mmhh')+
'&date='+t(date, 'ddmmyy')+
'&time='+t(date, 'mmhh')+
'&timeSel='+(args['departAt'] ? 'depart' : 'arrive')+
'&results='+limit+
'&typeOfTransport='+encodeURIComponent((args['transport']||[]).join(';'));
Expand Down Expand Up @@ -147,8 +158,8 @@ var IRail = (function(){
var uri = baseUri+'/liveboard/?format=json'+
'&station='+encodeURIComponent(args['station'])+
'&id='+encodeURIComponent(args['id'])+
'&date='+_.t(date, 'ddmmyy')+
'&time='+_.t(date, 'mmhh')+
'&date='+t(date, 'ddmmyy')+
'&time='+t(date, 'mmhh')+
'&arrdep='+(args['departAt'] ? 'DEP' : 'ARR');

insertScript(
Expand Down

0 comments on commit 33a5751

Please sign in to comment.