UNPKG

@mikezimm/npmfunctions

Version:
49 lines 1.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLocalMonths = exports.getYearMonthLabel = exports.getQuarter = void 0; //import { holidays, msPerDay, msPerHr, msPerMin, msPerMo, msPerQ, msPerWk, msPerYr, } from './constants'; //import { weekday3 } from './dayLabels'; var monthLabels_1 = require("./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) */ function getQuarter(date) { var month = date.getMonth() + 1; return (Math.ceil(month / 3)); } exports.getQuarter = getQuarter; /** * Created for GridCharts * @param theDate */ function getYearMonthLabel(theDate) { var year = theDate.getFullYear(); var month = theDate.getMonth(); var monthNo = (month + 1).toString(); var monthLabel = year + ' : ' + monthNo + '-' + monthLabels_1.monthStr3["en-us"][month]; return monthLabel; } exports.getYearMonthLabel = getYearMonthLabel; // export function getLocalMonths( local : string,format : string ){ //2022-08-29: Refactored return statement to fix compile warning. function getLocalMonths(local, format) { var months = []; var getMonth = function (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; } exports.getLocalMonths = getLocalMonths; //# sourceMappingURL=getLabels.js.map