You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
660 B

  1. class HoursMinutesSeconds {
  2. late int _days;
  3. late int _hours;
  4. late int _mins;
  5. late int _secs;
  6. HoursMinutesSeconds(int totalSeconds) {
  7. _days = (totalSeconds / 86400).floor();
  8. int daysInSec = _days * 86400;
  9. _hours = ((totalSeconds - daysInSec) / 3600).floor();
  10. int hoursInSec = (_hours * 3600);
  11. _mins = ((totalSeconds - daysInSec - hoursInSec) / 60).floor();
  12. int minsInSec = _mins * 60;
  13. _secs = totalSeconds - minsInSec - hoursInSec - daysInSec;
  14. }
  15. int getSeconds() {
  16. return _secs;
  17. }
  18. int getMinutes() {
  19. return _mins;
  20. }
  21. int getHours() {
  22. return _hours;
  23. }
  24. int getDays() {
  25. return _days;
  26. }
  27. }