Announcement

Collapse
No announcement yet.

fixed time display

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • fixed time display

    Howdy,
    is there any way (like toFixed) to specify that both digits of getMinute() get displayed? ie. 00 not 0?

    thanks
    Mark

  • #2
    if(getMinute()< 10)gMin = "0"+getMinute();

    might be a helpful suggestion

    Comment


    • #3
      yup, that would work, but I was hoping for something more eligent/built in ...

      Comment


      • #4
        flexie
        While there is no built-in function to display hours, minutes and seconds as two digits you can very easily create your own using the Function Library.
        For example copy the following code and save it in the FunctionLibrary folder as sampleFunctions.efsLib.

        PHP Code:
        function padTime(input){
            if(
        input<10
                var 
        ret "0"+input;
            else 
                var 
        ret input;
            return 
        ret;

        Then in your efs you would only need to add the call to the library outside of main after which you can call the function as in the example below

        PHP Code:
        var addLibrary("sampleFunctions.efsLib");//calls the library

        function main(){
            
        debugPrintln(x.padTime(getHour(0))+":"+x.padTime(getMinute(0))+" instead of "+getHour(0)+":"+getMinute(0))

        The result is shown in the image enclosed below
        Alex

        Comment


        • #5
          nice ... and works excellent.

          Thanks Alexis

          Mark

          Comment

          Working...
          X