@date-io/moment
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -6,2 +6,4 @@ import defaultMoment from 'moment'; | ||
var _b = _a === void 0 ? {} : _a, locale = _b.locale, moment = _b.moment; | ||
this.yearFormat = "YYYY"; | ||
this.yearMonthFormat = "MMMM YYYY"; | ||
this.dateTime12hFormat = "MMMM Do hh:mm a"; | ||
@@ -98,2 +100,5 @@ this.dateTime24hFormat = "MMMM Do HH:mm"; | ||
}; | ||
MomentUtils.prototype.setMonth = function (date, count) { | ||
return date.clone().month(count); | ||
}; | ||
MomentUtils.prototype.getMeridiemText = function (ampm) { | ||
@@ -114,2 +119,11 @@ return ampm === "am" ? "AM" : "PM"; | ||
}; | ||
MomentUtils.prototype.getMonthArray = function (date) { | ||
var firstMonth = date.clone().startOf("year"); | ||
var monthArray = [firstMonth]; | ||
while (monthArray.length < 12) { | ||
var prevMonth = monthArray[monthArray.length - 1]; | ||
monthArray.push(this.getNextMonth(prevMonth)); | ||
} | ||
return monthArray; | ||
}; | ||
MomentUtils.prototype.getYear = function (date) { | ||
@@ -172,3 +186,3 @@ return date.get("year"); | ||
MomentUtils.prototype.getCalendarHeaderText = function (date) { | ||
return date.format("MMMM YYYY"); | ||
return date.format(this.yearMonthFormat); | ||
}; | ||
@@ -184,2 +198,5 @@ MomentUtils.prototype.getYearText = function (date) { | ||
}; | ||
MomentUtils.prototype.getMonthText = function (date) { | ||
return date.format("MMMM"); | ||
}; | ||
MomentUtils.prototype.getDayText = function (date) { | ||
@@ -186,0 +203,0 @@ return date.format("D"); |
@@ -10,2 +10,4 @@ 'use strict'; | ||
var _b = _a === void 0 ? {} : _a, locale = _b.locale, moment = _b.moment; | ||
this.yearFormat = "YYYY"; | ||
this.yearMonthFormat = "MMMM YYYY"; | ||
this.dateTime12hFormat = "MMMM Do hh:mm a"; | ||
@@ -102,2 +104,5 @@ this.dateTime24hFormat = "MMMM Do HH:mm"; | ||
}; | ||
MomentUtils.prototype.setMonth = function (date, count) { | ||
return date.clone().month(count); | ||
}; | ||
MomentUtils.prototype.getMeridiemText = function (ampm) { | ||
@@ -118,2 +123,11 @@ return ampm === "am" ? "AM" : "PM"; | ||
}; | ||
MomentUtils.prototype.getMonthArray = function (date) { | ||
var firstMonth = date.clone().startOf("year"); | ||
var monthArray = [firstMonth]; | ||
while (monthArray.length < 12) { | ||
var prevMonth = monthArray[monthArray.length - 1]; | ||
monthArray.push(this.getNextMonth(prevMonth)); | ||
} | ||
return monthArray; | ||
}; | ||
MomentUtils.prototype.getYear = function (date) { | ||
@@ -176,3 +190,3 @@ return date.get("year"); | ||
MomentUtils.prototype.getCalendarHeaderText = function (date) { | ||
return date.format("MMMM YYYY"); | ||
return date.format(this.yearMonthFormat); | ||
}; | ||
@@ -188,2 +202,5 @@ MomentUtils.prototype.getYearText = function (date) { | ||
}; | ||
MomentUtils.prototype.getMonthText = function (date) { | ||
return date.format("MMMM"); | ||
}; | ||
MomentUtils.prototype.getDayText = function (date) { | ||
@@ -190,0 +207,0 @@ return date.format("D"); |
@@ -11,2 +11,4 @@ import defaultMoment from "moment"; | ||
locale?: string; | ||
yearFormat: string; | ||
yearMonthFormat: string; | ||
dateTime12hFormat: string; | ||
@@ -42,2 +44,3 @@ dateTime24hFormat: string; | ||
isSameDay(date: Moment, comparing: Moment): boolean; | ||
setMonth(date: Moment, count: number): defaultMoment.Moment; | ||
getMeridiemText(ampm: "am" | "pm"): "AM" | "PM"; | ||
@@ -48,2 +51,3 @@ startOfMonth(date: Moment): defaultMoment.Moment; | ||
getPreviousMonth(date: Moment): defaultMoment.Moment; | ||
getMonthArray(date: Moment): defaultMoment.Moment[]; | ||
getYear(date: Moment): number; | ||
@@ -60,2 +64,3 @@ setYear(date: Moment, year: number): defaultMoment.Moment; | ||
getDateTimePickerHeaderText(date: Moment): string; | ||
getMonthText(date: Moment): string; | ||
getDayText(date: Moment): string; | ||
@@ -62,0 +67,0 @@ getHourText(date: Moment, ampm: boolean): string; |
{ | ||
"name": "@date-io/moment", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Abstraction over common javascript date management libraries", | ||
@@ -12,3 +12,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@date-io/core": "^1.0.1" | ||
"@date-io/core": "^1.0.2" | ||
}, | ||
@@ -18,3 +18,4 @@ "devDependencies": { | ||
"moment": "^2.22.2", | ||
"rollup": "^0.66.6" | ||
"rollup": "^0.66.6", | ||
"typescript": "^3.2.4" | ||
}, | ||
@@ -45,3 +46,3 @@ "scripts": { | ||
"license": "MIT", | ||
"gitHead": "85bac554cf41ec50e135e2123f1d1c6691bcaa7f" | ||
"gitHead": "db6ddb0b74fefc66aa681335c5880cdc656412b7" | ||
} |
@@ -16,2 +16,6 @@ import defaultMoment from "moment"; | ||
public yearFormat = "YYYY"; | ||
public yearMonthFormat = "MMMM YYYY"; | ||
public dateTime12hFormat = "MMMM Do hh:mm a"; | ||
@@ -60,3 +64,3 @@ | ||
public getDiff(date: Moment, comparing: Moment) { | ||
public getDiff(date: Moment, comparing: Moment | string) { | ||
return date.diff(comparing); | ||
@@ -143,2 +147,6 @@ } | ||
public setMonth(date: Moment, count: number) { | ||
return date.clone().month(count); | ||
} | ||
public getMeridiemText(ampm: "am" | "pm") { | ||
@@ -164,2 +172,14 @@ return ampm === "am" ? "AM" : "PM"; | ||
public getMonthArray(date: Moment) { | ||
const firstMonth = date.clone().startOf("year"); | ||
const monthArray = [firstMonth]; | ||
while (monthArray.length < 12) { | ||
const prevMonth = monthArray[monthArray.length - 1]; | ||
monthArray.push(this.getNextMonth(prevMonth)); | ||
} | ||
return monthArray; | ||
} | ||
public getYear(date: Moment) { | ||
@@ -238,3 +258,3 @@ return date.get("year"); | ||
public getCalendarHeaderText(date: Moment) { | ||
return date.format("MMMM YYYY"); | ||
return date.format(this.yearMonthFormat); | ||
} | ||
@@ -254,2 +274,6 @@ | ||
public getMonthText(date: Moment) { | ||
return date.format("MMMM"); | ||
} | ||
public getDayText(date: Moment) { | ||
@@ -256,0 +280,0 @@ return date.format("D"); |
26895
718
4
Updated@date-io/core@^1.0.2