Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getPlainEnglishTimefromDays(daysValue:Number):String {
  2.     var text:String = "";
  3.     var days:Number = Math.abs(daysValue);
  4.     if (days < 1) {
  5.         var hours:Number = days * 24;
  6.         if (hours < 1) {
  7.             var minutes:int = Math.floor(hours * 60);
  8.             text = minutes + " minute";
  9.             if (minutes != 1) {
  10.                 text += "s";
  11.             }
  12.         } else {
  13.             text = Math.floor(hours) + " hour";
  14.             if (Math.floor(hours) != 1) {
  15.                 text += "s";
  16.             }
  17.         }
  18.     } else if (days > 0) {
  19.         text = Math.floor(days) + " day";
  20.         if (Math.floor(days) != 1) {
  21.             text += "s";
  22.         }
  23.     }
  24.     return text;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement