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

Break: NOW() returning ISO format #1431

Merged
merged 2 commits into from
Sep 24, 2022
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
4 changes: 2 additions & 2 deletions src/61date.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ stdfn.NOW = function () {
var d = new Date();
var s =
d.getFullYear() +
'.' +
'-' +
('0' + (d.getMonth() + 1)).substr(-2) +
'.' +
'-' +
('0' + d.getDate()).substr(-2);
s +=
' ' +
Expand Down
24 changes: 24 additions & 0 deletions test/test845.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('../dist/alasql');
}

/*
Test for issue #845
*/

var test = '845'; // insert test file number

describe('Test ' + test + ' - use NOW() function', function () {
it('1. NOW()', function () {
var res = alasql("SELECT NOW() AS now");
//2022-02-25 19:21:27.839
assert(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}/.test(res[0].now));
});

it('2. CONVERT with NOW() as an argument', function () {
var res = alasql("SELECT CONVERT(STRING,NOW(),1) AS conv");
//02/25/22
assert(/\d{2}\/\d{2}\/\d{2}/.test(res[0].conv));
});
});