@jamesrock/rockjs 1.39.0 → 1.40.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 +5 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -24,7 +24,8 @@ export const formatNumber = (n) => numberFormatter.format(n);
24
24
  export const formatCurrency = (n) => currencyFormatter.format(n);
25
25
  export const formatDate = (date, type = 'short') => date.toLocaleDateString('en-GB', { dateStyle: type });
26
26
  export const getDateString = (type = 'short') => formatDate(new Date(), type);
27
- export const getTimeString = (type = 'short') => new Date().toLocaleTimeString('en-GB', { timeStyle: type });
27
+ export const formatTime = (date, type = 'short') => date.toLocaleTimeString('en-GB', { timeStyle: type });
28
+ export const getTimeString = (type = 'short') => formatTime(new Date(), type);
28
29
  export const getDateTimeString = (type = 'short') => `${getDateString(type)} ${getTimeString(type)}`;
29
30
  export const isValidKey = (key, options) => options.includes(key);
30
31
  export const makeArray = (length, mapper = (a, i) => i) => Array.from({length}, mapper);
@@ -692,15 +693,15 @@ export class Time {
692
693
  getHours = (ms) => floorTo(ms / this.hour, this.accuracy);
693
694
  getDays = (ms) => floorTo(ms / this.day, this.accuracy);
694
695
  getYears = (ms) => floorTo(ms / this.year, this.accuracy);
696
+ getMillisecondsInSecond = (ms) => (ms % this.second);
695
697
  getMillisecondsInMinute = (ms) => (ms % this.minute);
696
698
  getMillisecondsInHour = (ms) => (ms % this.hour);
697
699
  getMillisecondsInDay = (ms) => (ms % this.day);
698
700
  getMillisecondsInYear = (ms) => (ms % this.year);
701
+ getSecondsInMinute = (ms) => this.getSeconds(this.getMillisecondsInMinute(ms));
702
+ getMinutesInHour = (ms) => this.getMinutes(this.getMillisecondsInHour(ms));
699
703
  getHoursInDay = (ms) => this.getHours(this.getMillisecondsInDay(ms));
700
704
  getDaysInYear = (ms) => this.getDays(this.getMillisecondsInYear(ms));
701
- getMinutesInHour = (ms) => this.getMinutes(this.getMillisecondsInHour(ms));
702
- getSecondsInMinute = (ms) => this.getSeconds(this.getMillisecondsInMinute(ms));
703
- format = (ms) => `${pad(this.getMinutesInHour(ms))}:${pad(this.getSecondsInMinute(ms))}`;
704
705
  };
705
706
 
706
707
  export class PlayingCard extends DisplayObject {
@@ -1028,4 +1029,3 @@ export const createOption = makeOption;
1028
1029
  export const createHeading = makeHeading;
1029
1030
  export const createRadio = makeRadio;
1030
1031
  export const createLabel = makeLabel;
1031
- export const formatTime = (ms) => new Time().format(ms);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",