angular-timer icon indicating copy to clipboard operation
angular-timer copied to clipboard

Timer displaying 0-1:0-1:0-1

Open Sanath1 opened this issue 9 years ago • 8 comments

We faced timer issue. in the local system, the format it is displaying 00:00:00. But when we are deployed the same code in to public server, then the timer, it is displaying as 01-0-2-01 format. How can we change the format to 00:00:00 for front end.

Help me you have any solution...

Sanath1 avatar Feb 15 '16 11:02 Sanath1

Got the same problem. Only after minification

morgs32 avatar Mar 16 '16 16:03 morgs32

+1

almothafar avatar Aug 11 '16 10:08 almothafar

+1

guiguez38 avatar Nov 15 '16 09:11 guiguez38

I have solved the problem by changing 3 methods:

$scope.start = $element[0].start = function () {
                 var now = moment();
                  var startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : null;
                  if (!startTime || startTime > now) {
                      $scope.startTime = now;
                  } else {
                      $scope.startTime = startTime;
                  }
                  var endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null;
                  if (!endTime || endTime < now) {
                      $scope.endTime = null;
                  } else {
                      $scope.endTime = endTime;
                  }
                  if (!angular.isNumber($scope.countdown)) {
                      $scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
                  }
                  resetTimeout();
                  tick();
                  $scope.isRunning = true;
              };
$scope.reset = $element[0].reset = function () {
                  var now = moment();
                  var startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : null;
                  if (!startTime || startTime > now) {
                      $scope.startTime = now;
                  } else {
                      $scope.startTime = startTime;
                  }
                  var endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null;
                  if (!endTime || endTime < now) {
                      $scope.endTime = null;
                  } else {
                      $scope.endTime = endTime;
                  }
                  $scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
                  resetTimeout();
                  tick();
                  $scope.isRunning = false;
                  $scope.clear();
              };
function calculateTimeUnits() {
          var timeUnits = {}; //will contains time with units

          if ($attrs.startTime !== undefined){
            $scope.millis = moment().diff(moment($scope.startTime));
          }
         ....
};

guiguez38 avatar Nov 15 '16 14:11 guiguez38

If anyone finds this later, I was using pug (formerly jade) to render HTML. Putting a variable in quotes wasn't rendering the variable for it's value, but sending in the string. Normally putting the variable name in strings is how they get rendered, but here it was just passing the string startTime in, causing it to show as 0-1 : 0-1 : 0-1 startTime wasn't undefined, and $scope.millis after the if statement from calculateTimeUnits (as shown above) was returning a value of -1.

timer(start-time='startTime' autostart='false' interval='1000') {{hhours}} : {{mminutes}} : {{sseconds}} Fixed: timer(start-time=startTime autostart='false' interval='1000') {{hhours}} : {{mminutes}} : {{sseconds}}

TShaunik avatar Jul 07 '17 20:07 TShaunik

I have the same problem:

image

Html code is:

<timer start-time="tableWait[kq].data[tableWait[kq].data.length-1].waitingTime" interval="1000">{{hhours}}:{{mminutes}}:{{sseconds}}</timer>

alepolidori avatar Oct 18 '17 15:10 alepolidori

Any news on that ?

alepolidori avatar Nov 20 '17 15:11 alepolidori

+1

xmdevelop avatar Oct 05 '18 16:10 xmdevelop