var jarvis = jarvis || angular.module('jarvis', []);

jarvis.controller('AtbCtrl', ['$scope',
  function ($scope) {
    'use strict';

    $scope.$on('atb', function (ev, body) {
      body.departures.map(function (d) {
        var departureTime = moment(d.registeredDepartureTime),
          now = moment();
        if (departureTime.isBefore(now)) {
          // BusBuddy sometimes returns dates in the past
          departureTime.set('year', now.get('year'));
          departureTime.set('month', now.get('month'));
          departureTime.set('day', now.get('day'));
        }
        d.departureTime = departureTime;
      });
      if (body.departures.length > 0) {
        body.next = body.departures[0];
        body.upcoming = body.departures.slice(1, 5);
      } else {
        body.next = null;
        body.upcoming = [];
      }
      angular.extend($scope, body);
    });

  }
]);

@@ -544,17 +544,18 @@
 .set('da
-y
+te
 ', now.g
@@ -560,17 +560,18 @@
 .get('da
-y
+te
 '));%0A   

Fix invalid unit in date correction