@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
43 lines • 1.59 kB
JavaScript
//import { holidays, msPerDay, msPerHr, msPerMin, msPerMo, msPerQ, msPerWk, msPerYr, } from './constants';
//import { weekday3 } from './dayLabels';
import { monthStr3 } from './monthLabels';
//import { ISO8601_week_no, getDayOfWeek } from './weeks';
//import { IDeltaDaysArray, ITheTime } from './Interfaces';
// import { getQuarter, getYearMonthLabel, getLocalMonths, } from '@mikezimm/npmfunctions/dist/Services/Time/getLabels';
/**
* Copied from PivotTiles
* @param date : Format = new Date() or new Date(2015, 1, 21)
*/
export function getQuarter(date) {
var month = date.getMonth() + 1;
return (Math.ceil(month / 3));
}
/**
* Created for GridCharts
* @param theDate
*/
export function getYearMonthLabel(theDate) {
let year = theDate.getFullYear();
let month = theDate.getMonth();
let monthNo = (month + 1).toString();
let monthLabel = year + ' : ' + monthNo + '-' + monthStr3["en-us"][month];
return monthLabel;
}
// export function getLocalMonths( local : string,format : string ){
//2022-08-29: Refactored return statement to fix compile warning.
export function getLocalMonths(local, format) {
let months = [];
let getMonth = (idx) => {
var objDate = new Date();
objDate.setDate(1);
objDate.setMonth(idx - 1);
var locale = local, month = objDate.toLocaleString(locale, { month: format });
return month;
};
var i;
for (i = 1; i < 12; i++) {
months.push(getMonth(i));
}
return months;
}
//# sourceMappingURL=getLabels.js.map