@jamesrock/rockjs 1.38.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.
- package/index.js +6 -6
- 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
|
|
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 {
|
|
@@ -959,7 +960,7 @@ export class Tempo {
|
|
|
959
960
|
this.taps.push(now);
|
|
960
961
|
|
|
961
962
|
if(this.taps.length > 1 && now - this.taps[this.taps.length - 2] > 2000) {
|
|
962
|
-
taps = [now];
|
|
963
|
+
this.taps = [now];
|
|
963
964
|
return base;
|
|
964
965
|
};
|
|
965
966
|
|
|
@@ -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);
|