Improve the readability of tomorrow.js (solved #775)
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
const tomorrow = (long = false) => {
|
||||
const tomorrow = () => {
|
||||
let t = new Date();
|
||||
t.setDate(t.getDate() + 1);
|
||||
const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||
t.getDate()
|
||||
).padStart(2, '0')}`;
|
||||
return !long ? ret : `${ret}T00:00:00`;
|
||||
return t.toISOString().split('T')[0];
|
||||
};
|
||||
|
||||
module.exports = tomorrow;
|
||||
|
||||
@ -4,6 +4,10 @@ const tomorrow = require('./tomorrow.js');
|
||||
test('tomorrow is a Function', () => {
|
||||
expect(tomorrow).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Returns the correct type', () => {
|
||||
expect(typeof tomorrow()).toBe('string');
|
||||
});
|
||||
|
||||
const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1);
|
||||
const t2 = new Date(tomorrow());
|
||||
test('Returns the correct year', () => {
|
||||
|
||||
Reference in New Issue
Block a user