@date-io/moment
Advanced tools
Comparing version 2.5.1 to 2.6.0
@@ -41,2 +41,19 @@ import defaultMoment from 'moment'; | ||
}; | ||
MomentUtils.prototype.getFormatHelperText = function (format) { | ||
var _this = this; | ||
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6 | ||
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g; | ||
return format | ||
.match(localFormattingTokens) | ||
.map(function (token) { | ||
var firstCharacter = token[0]; | ||
if (firstCharacter === "L" || firstCharacter === ";") { | ||
return _this.moment.localeData().longDateFormat(token); | ||
} | ||
return token; | ||
}) | ||
.join("") | ||
.replace(/a/gi, "(a|p)m") | ||
.toLocaleLowerCase(); | ||
}; | ||
MomentUtils.prototype.getCurrentLocaleCode = function () { | ||
@@ -188,3 +205,6 @@ return this.locale || this.moment.locale(); | ||
MomentUtils.prototype.mergeDateAndTime = function (date, time) { | ||
return this.setMinutes(this.setHours(date, this.getHours(time)), this.getMinutes(time)); | ||
return date | ||
.hour(time.hour()) | ||
.minute(time.minute()) | ||
.second(time.second()); | ||
}; | ||
@@ -191,0 +211,0 @@ MomentUtils.prototype.getWeekdays = function () { |
@@ -45,2 +45,19 @@ 'use strict'; | ||
}; | ||
MomentUtils.prototype.getFormatHelperText = function (format) { | ||
var _this = this; | ||
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6 | ||
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g; | ||
return format | ||
.match(localFormattingTokens) | ||
.map(function (token) { | ||
var firstCharacter = token[0]; | ||
if (firstCharacter === "L" || firstCharacter === ";") { | ||
return _this.moment.localeData().longDateFormat(token); | ||
} | ||
return token; | ||
}) | ||
.join("") | ||
.replace(/a/gi, "(a|p)m") | ||
.toLocaleLowerCase(); | ||
}; | ||
MomentUtils.prototype.getCurrentLocaleCode = function () { | ||
@@ -192,3 +209,6 @@ return this.locale || this.moment.locale(); | ||
MomentUtils.prototype.mergeDateAndTime = function (date, time) { | ||
return this.setMinutes(this.setHours(date, this.getHours(time)), this.getMinutes(time)); | ||
return date | ||
.hour(time.hour()) | ||
.minute(time.minute()) | ||
.second(time.second()); | ||
}; | ||
@@ -195,0 +215,0 @@ MomentUtils.prototype.getWeekdays = function () { |
@@ -15,2 +15,3 @@ import defaultMoment from "moment"; | ||
is12HourCycleInCurrentLocale(): boolean; | ||
getFormatHelperText(format: string): string; | ||
getCurrentLocaleCode(): string; | ||
@@ -17,0 +18,0 @@ parse(value: string, format: string): defaultMoment.Moment; |
{ | ||
"name": "@date-io/moment", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "Abstraction over common javascript date management libraries", | ||
@@ -12,3 +12,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@date-io/core": "^2.5.0" | ||
"@date-io/core": "^2.6.0" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
"license": "MIT", | ||
"gitHead": "b7acda842159519578c0aa345e5c693232aacd03" | ||
"gitHead": "d6db25c9863530a6d5934a2f8b97b1f0162d967d" | ||
} |
@@ -1,2 +0,2 @@ | ||
import defaultMoment from "moment"; | ||
import defaultMoment, { LongDateFormatKey } from "moment"; | ||
import { IUtils, DateIOFormats } from "@date-io/core/IUtils"; | ||
@@ -58,2 +58,20 @@ | ||
public getFormatHelperText(format: string) { | ||
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6 | ||
const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g; | ||
return format | ||
.match(localFormattingTokens) | ||
.map(token => { | ||
const firstCharacter = token[0]; | ||
if (firstCharacter === "L" || firstCharacter === ";") { | ||
return this.moment.localeData().longDateFormat(token as LongDateFormatKey); | ||
} | ||
return token; | ||
}) | ||
.join("") | ||
.replace(/a/gi, "(a|p)m") | ||
.toLocaleLowerCase(); | ||
} | ||
public getCurrentLocaleCode() { | ||
@@ -252,6 +270,6 @@ return this.locale || this.moment.locale(); | ||
public mergeDateAndTime(date: Moment, time: Moment) { | ||
return this.setMinutes( | ||
this.setHours(date, this.getHours(time)), | ||
this.getMinutes(time) | ||
); | ||
return date | ||
.hour(time.hour()) | ||
.minute(time.minute()) | ||
.second(time.second()); | ||
} | ||
@@ -258,0 +276,0 @@ |
31978
857
Updated@date-io/core@^2.6.0