Skip to content
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
1 change: 0 additions & 1 deletion packages/cli-repl/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ describe('e2e', function() {
await shell.waitForPrompt();
shell.assertNoErrors();

await shell.executeLine('Date.now = () => new Date().getTime()'); // MONGOSH-597 hack
await shell.executeLine(`use ${dbName}`);
await shell.executeLine('db.test.insertOne({ d: new Date("2021-04-07T11:24:54+02:00") })');
shell.writeInputLine(`load(${JSON.stringify(require.resolve('lodash'))})`);
Expand Down
16 changes: 0 additions & 16 deletions packages/shell-api/src/shell-bson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,6 @@ describe('Shell BSON', () => {
expect(s.code).to.equal('');
});
});
describe('Date', () => {
it('returns string without new', () => {
expect(shellBson.Date()).to.be.a('string');
});
it('accepts ISO args', () => {
expect((new (shellBson.Date as any)(1) as Date).getTime()).to.equal(1);
expect((new (shellBson.Date as any)(1, 2) as Date).getTime()).to.equal(-2172355200000);
expect((new (shellBson.Date as any)(1, 2, 3, 4, 5) as Date).getTime()).to.equal(-2172167700000);
});
it('returns now object with new', () => {
const date = new (shellBson.Date as any)();
const cDate = new Date();
expect(typeof date).to.equal('object');
expect(date.getFullYear()).to.equal(cDate.getFullYear());
});
});
describe('ISODate', () => {
it('ISODate is always object', () => {
const date = new (shellBson.ISODate as any)();
Expand Down
19 changes: 0 additions & 19 deletions packages/shell-api/src/shell-bson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ function constructHelp(className: string): Help {
return new Help(classHelp);
}

type DateConstructorArguments = [ any?, any?, ...any[] ];

function dateHelper(...args: DateConstructorArguments): Date {
if (args.length === 0) {
return new Date();
}
if (args.length === 1) {
return new Date(args[0]);
}
return new Date(Date.UTC(...args));
}

/**
* This method modifies the BSON class passed in as argument. This is required so that
* we can have help, serverVersions, and other metadata on the bson classes constructed by the user.
Expand Down Expand Up @@ -112,13 +100,6 @@ export default function constructShellBson(bson: typeof BSON, printWarning: (msg
printWarning('NumberLong: specifying a number as argument is deprecated and may lead to loss of precision');
return bson.Long.fromInt(s);
},
Date: function(...args: DateConstructorArguments): Date | string {
const date = dateHelper(...args);
if (new.target) {
return date;
}
return date.toString();
},
ISODate: function(input?: string): Date {
if (!input) input = new Date().toISOString();
const isoDateRegex =
Expand Down