added constant for years range + added comment for month quirk
This commit is contained in:
@@ -6,10 +6,12 @@ define([
|
|||||||
Moment
|
Moment
|
||||||
) {
|
) {
|
||||||
class FormFieldDateYear extends React.Component {
|
class FormFieldDateYear extends React.Component {
|
||||||
|
const yearsRange = 100;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const years = [];
|
const years = [];
|
||||||
const currentYear = Moment().year();
|
const currentYear = Moment().year();
|
||||||
for (let i = currentYear; i >= currentYear - 100; i--) {
|
for (let i = currentYear; i >= currentYear - yearsRange; i--) {
|
||||||
years.push((
|
years.push((
|
||||||
<option
|
<option
|
||||||
key={ i }
|
key={ i }
|
||||||
@@ -100,6 +102,8 @@ define([
|
|||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
year: Moment.unix(timeStamp).year(),
|
year: Moment.unix(timeStamp).year(),
|
||||||
|
// Moment returns the month as [0..11]
|
||||||
|
// We increment it to match PHP's mktime() which expects [1..12]
|
||||||
month: Moment.unix(timeStamp).month() + 1,
|
month: Moment.unix(timeStamp).month() + 1,
|
||||||
day: Moment.unix(timeStamp).date()
|
day: Moment.unix(timeStamp).date()
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user