Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first set date 2021-04-01, and set date 2021-05-31, display 2021-05-01 bug #794

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc
Expand Up @@ -2,8 +2,5 @@
"presets": [
"@babel/preset-react",
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ sudo: false
os:
- linux
node_js:
- '8'
- '12'
- 'stable'
script:
- npm run lint
Expand Down
38 changes: 16 additions & 22 deletions package.json
Expand Up @@ -41,32 +41,29 @@
"react": "^16.5.0"
},
"devDependencies": {
"@babel/core": "7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/preset-env": "^7.7.7",
"@babel/preset-react": "^7.7.4",
"@svgr/webpack": "4.3.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/react": "^16.5.0",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"@babel/preset-react": "^7.13.13",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.6.0",
"@types/react": "^16.14.2",
"@typescript-eslint/eslint-plugin": "^2.8.0",
"@typescript-eslint/parser": "^2.8.0",
"babel-eslint": "10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "8.0.6",
"babel-plugin-named-asset-import": "^0.3.5",
"babel-loader": "8.2.2",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"css-loader": "3.2.0",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"enzyme": "^3.0.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.6.0",
"eslint-config-react-app": "^5.1.0",
"eslint-loader": "3.0.2",
"eslint-plugin-flowtype": "3.13.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.16.0",
Expand All @@ -75,11 +72,8 @@
"fs-extra": "^8.1.0",
"html-webpack-plugin": "4.0.0-beta.5",
"identity-obj-proxy": "3.0.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.2",
"jsdom": "^7.0.2",
"jest": "^26.6.3",
"jest-watch-typeahead": "0.6.1",
"mini-css-extract-plugin": "0.8.0",
"moment": "^2.16.0",
"moment-timezone": "^0.5.13",
Expand All @@ -91,14 +85,14 @@
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"pre-commit": "^1.1.3",
"react": "^16.5.0",
"react-app-polyfill": "^1.0.5",
"react-dev-utils": "10.1.0",
"react-dom": "^16.5.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-onclickoutside": "^6.9.0",
"react-test-renderer": "^16.5.0",
"resolve": "1.12.2",
"resolve-url-loader": "3.1.1",
"resolve-url-loader": "3.1.2",
"sass-loader": "8.0.0",
"semver": "6.3.0",
"style-loader": "1.0.0",
Expand Down Expand Up @@ -138,7 +132,7 @@
"<rootDir>/test/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/test/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"testEnvironment": "jsdom",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
Expand Down
13 changes: 7 additions & 6 deletions src/DateTime.js
Expand Up @@ -338,17 +338,18 @@ export default class Datetime extends React.Component {
let updateOnView = this.getUpdateOn( this.getFormat('date') );
let viewDate = this.state.viewDate.clone();

// Set the value into day/month/year
viewDate[ this.viewToMethod[currentView] ](
parseInt( e.target.getAttribute('data-value'), 10 )
);

// Need to set month and year will for days view (prev/next month)
// Must first set month and year, then set day,
// need to set month and year will for days view (prev/next month)
if ( currentView === 'days' ) {
viewDate.month( parseInt( e.target.getAttribute('data-month'), 10 ) );
viewDate.year( parseInt( e.target.getAttribute('data-year'), 10 ) );
}

// Set the value into day/month/year
viewDate[ this.viewToMethod[currentView] ](
parseInt( e.target.getAttribute('data-value'), 10 )
);

let update = {viewDate: viewDate};
if ( currentView === updateOnView ) {
update.selectedDate = viewDate.clone();
Expand Down