@jamesrock/rockjs 1.32.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +17 -43
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -646,56 +646,30 @@ export class Collection extends Array {
646
646
  };
647
647
 
648
648
  export class Time {
649
+ constructor(accuracy = 1) {
650
+ this.accuracy = accuracy;
651
+ };
649
652
  second = 1000;
650
653
  minute = (this.second * 60);
651
654
  hour = (this.minute * 60);
652
655
  day = (this.hour * 24);
653
656
  year = (this.day * 365);
654
- getSeconds(ms) {
655
- return floorTo(ms / this.second);
656
- };
657
- getMinutes(ms) {
658
- return floorTo(ms / this.minute);
659
- };
660
- getHours(ms) {
661
- return floorTo(ms / this.hour);
662
- };
663
- getDays(ms) {
664
- return floorTo(ms / this.day);
665
- };
666
- getYears(ms) {
667
- return floorTo(ms / this.year);
668
- };
669
- getMillisecondsInHour(ms) {
670
- return (ms % this.hour);
671
- };
672
- getMillisecondsInMinute(ms) {
673
- return (ms % this.minute);
674
- };
675
- getMillisecondsInDay(ms) {
676
- return (ms % this.day);
677
- };
678
- getSecondsInDay(ms) {
679
- return (this.getSeconds(ms) % this.day);
680
- };
681
- getMinutesInDay(ms) {
682
- return (this.getMinutes(ms) % this.day);
683
- };
684
- getHoursInDay(ms) {
685
- return (this.getHours(ms) % this.day);
686
- };
687
- getDaysInYear(ms) {
688
- return (this.getDays(ms) % this.year);
689
- };
690
- getMinutesInHour(ms) {
691
- return floorTo(this.getMillisecondsInHour(ms) / this.minute);
692
- };
693
- getSecondsInMinute(ms) {
694
- return floorTo(this.getMillisecondsInMinute(ms) / this.second);
695
- };
657
+ getSeconds = (ms) => floorTo(ms / this.second, this.accuracy);
658
+ getMinutes = (ms) => floorTo(ms / this.minute, this.accuracy);
659
+ getHours = (ms) => floorTo(ms / this.hour, this.accuracy);
660
+ getDays = (ms) => floorTo(ms / this.day, this.accuracy);
661
+ getYears = (ms) => floorTo(ms / this.year, this.accuracy);
662
+ getMillisecondsInMinute = (ms) => (ms % this.minute);
663
+ getMillisecondsInHour = (ms) => (ms % this.hour);
664
+ getMillisecondsInDay = (ms) => (ms % this.day);
665
+ getMillisecondsInYear = (ms) => (ms % this.year);
666
+ getHoursInDay = (ms) => this.getHours(this.getMillisecondsInDay(ms));
667
+ getDaysInYear = (ms) => this.getDays(this.getMillisecondsInYear(ms));
668
+ getMinutesInHour = (ms) => this.getMinutes(this.getMillisecondsInHour(ms));
669
+ getSecondsInMinute = (ms) => this.getSeconds(this.getMillisecondsInMinute(ms));
696
670
  formatSeconds = (ms) => pad(this.getSecondsInMinute(ms));
697
671
  formatMinutes = (ms) => pad(this.getMinutesInHour(ms));
698
- formatHours = (ms) => pad(this.getHours(ms));
672
+ formatHours = (ms) => pad(this.getHoursInDay(ms));
699
673
  format = (ms) => `${this.formatMinutes(ms)}:${this.formatSeconds(ms)}`;
700
674
  };
701
675
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.32.0",
3
+ "version": "1.34.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",