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

Fix JavaScript parse reference date #138

Merged
merged 2 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions JavaScript/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ IF ERRORLEVEL 1 (
EXIT /B
)

IF NOT EXIST "node_modules" (
ECHO # Installing dependencies - npm install
CALL npm i
)
REM Prebuild each sub-module referenced on main module
ECHO.
ECHO # Building recognizers number module
CALL npm run prebuild-number

IF NOT EXIST "recognizers-number/node_modules" (
ECHO # Building recognizers number module
CALL npm run prebuild-number
)
ECHO.
ECHO # Building recognizers number-with-unit module
CALL npm run prebuild-number-with-unit

IF NOT EXIST "recognizers-number-with-unit/node_modules" (
ECHO # Building recognizers number-with-unit module
CALL npm run prebuild-number-with-unit
)
ECHO.
ECHO # Building recognizers date-time module
CALL npm run prebuild-date-time

IF NOT EXIST "recognizers-date-time/node_modules" (
ECHO # Building recognizers date-time module
CALL npm run prebuild-date-time
)
REM Build main module
ECHO.
ECHO # Installing dependencies - npm install
CALL npm i

ECHO.
ECHO # Building - npm run build
Expand Down
7 changes: 6 additions & 1 deletion JavaScript/test/runner-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,14 @@ function getModel(config) {
return findModel(options, cultureCode);
}

function parseISOLocal(s) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment in the code here to explain why this was needed? It will be helpful in the future.

var b = s.split(/\D/);
return new Date(b[0], b[1]-1, b[2], b[3], b[4], b[5]);
}

function getReferenceDate(testCase) {
if (testCase.Context && testCase.Context.ReferenceDateTime) {
return new Date(Date.parse(testCase.Context.ReferenceDateTime));
return parseISOLocal(testCase.Context.ReferenceDateTime);
}

return null;
Expand Down