Advertisement
Guest User

seconds to hms

a guest
May 13th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. my Int $sec-in-hour = 3600;
  2. my Int $sec-in-min = 60;
  3.  
  4. sub MAIN (Int $seconds)
  5. {
  6. say hms($seconds);
  7. }
  8.  
  9. sub hms (Int $seconds is rw)
  10. {
  11. my (Int $hours, Int $minutes);
  12.  
  13. $hours = $seconds div $sec-in-hour;
  14. $seconds %= $sec-in-hour if $hours > 0;
  15. $minutes = $seconds div $sec-in-min;
  16. $seconds %= $sec-in-min if $minutes > 0;
  17.  
  18. return "$hours hours, $minutes minutes, $seconds seconds";
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement