dce-reactkit 3.3.4 → 3.3.5
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/dist/cjs/index.js +46 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/esm/index.js +46 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/index.d.ts +20 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
package/dist/cjs/index.js
CHANGED
|
@@ -5632,6 +5632,51 @@ const compareArraysByProp = (a, b, prop) => {
|
|
|
5632
5632
|
});
|
|
5633
5633
|
};
|
|
5634
5634
|
|
|
5635
|
+
/**
|
|
5636
|
+
* Get current time info in local time
|
|
5637
|
+
* @author Gabe Abrams
|
|
5638
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
5639
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
5640
|
+
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
5641
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
5642
|
+
*/
|
|
5643
|
+
const getLocalTimeInfo = (dateOrTimestamp) => {
|
|
5644
|
+
// Create a time string
|
|
5645
|
+
let d;
|
|
5646
|
+
if (!dateOrTimestamp) {
|
|
5647
|
+
// Use now
|
|
5648
|
+
d = new Date();
|
|
5649
|
+
}
|
|
5650
|
+
else if (typeof dateOrTimestamp === 'number') {
|
|
5651
|
+
// Convert to date
|
|
5652
|
+
d = new Date(dateOrTimestamp);
|
|
5653
|
+
}
|
|
5654
|
+
else {
|
|
5655
|
+
// Already a date
|
|
5656
|
+
d = dateOrTimestamp;
|
|
5657
|
+
}
|
|
5658
|
+
// Create all time numbers
|
|
5659
|
+
const timestamp = d.getTime();
|
|
5660
|
+
const year = d.getFullYear();
|
|
5661
|
+
const month = d.getMonth() + 1;
|
|
5662
|
+
const day = d.getDate();
|
|
5663
|
+
const hour = d.getHours();
|
|
5664
|
+
const isPM = hour >= 12;
|
|
5665
|
+
const hour12 = hour % 12;
|
|
5666
|
+
const minute = d.getMinutes();
|
|
5667
|
+
// Return
|
|
5668
|
+
return {
|
|
5669
|
+
timestamp,
|
|
5670
|
+
year,
|
|
5671
|
+
month,
|
|
5672
|
+
day,
|
|
5673
|
+
hour,
|
|
5674
|
+
hour12,
|
|
5675
|
+
isPM,
|
|
5676
|
+
minute,
|
|
5677
|
+
};
|
|
5678
|
+
};
|
|
5679
|
+
|
|
5635
5680
|
/**
|
|
5636
5681
|
* Days of the week
|
|
5637
5682
|
* @author Gabe Abrams
|
|
@@ -5695,6 +5740,7 @@ exports.forceNumIntoBounds = forceNumIntoBounds;
|
|
|
5695
5740
|
exports.genCSV = genCSV;
|
|
5696
5741
|
exports.genRouteHandler = genRouteHandler;
|
|
5697
5742
|
exports.getHumanReadableDate = getHumanReadableDate;
|
|
5743
|
+
exports.getLocalTimeInfo = getLocalTimeInfo;
|
|
5698
5744
|
exports.getMonthName = getMonthName;
|
|
5699
5745
|
exports.getOrdinal = getOrdinal;
|
|
5700
5746
|
exports.getPartOfDay = getPartOfDay;
|