     task.weighting = $scope.task.weight
     task.unit_id = $scope.unit.id
     task.upload_requirements = JSON.stringify $scope.task.upload_requirements
+    # task.upload_requirements = $scope.task.upload_requirements
+    if task.target_date && task.target_date.getMonth
+      tgt = task.target_date
+      task.target_date = "#{tgt.getFullYear()}-#{tgt.getMonth() + 1}-#{tgt.getDate()}"
+    
     task.description = $scope.task.desc
     
     if $scope.isNew

  
  $scope.removeUpReq = (upReq) ->
    $scope.task.upload_requirements = $scope.task.upload_requirements.filter (anUpReq) -> anUpReq.key isnt upReq.key
    
  $scope.saveTask = () ->
    # Map the task to upload to the appropriate fields
    task = $scope.task

      TaskDefinition.update( { id: task.id, task_def: task } ).$promise.then (
        (response) ->
          $modalInstance.close(response)
          alertService.add("success", "#{response.name} Updated", 5000)
          populate_task($scope.task, response)
      ),
      (
        (response) ->
