Dates with a year from 1 to 100 are returned as 19xx
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- javascript, node.js
- Domain
- database
Research direction
Start in lib/settings.js at the _makeDate method and reproduce the reported behavior with the supplied runnable Node.js script. Verify that dates using years from 1 to 100 retain their requested years, while preserving the existing handling for the other listed years.
Written by the indexing model from the issue text.
Description
- What versions are you using?
6.0.0 - Is it an error or a hang or a crash?
error - What error(s) or behavior you are seeing?
Dates with a year from 1 to 100 are returned as 19xx - Include a runnable Node.js script that shows the problem.
const years = [
9999,
2023,
1000,
100,
10,
1,
-1,
-10,
-100
-1000,
];
const sql = `SELECT ${years.map(year => `DATE '${year}-01-01'`).join(', ')} FROM DUAL`;
const {rows: [row]} = await conn.execute(sql);
deepEqual(years, row.map(d=>d.getFullYear()));
The reason is related to the behavior of the Date constructor.
Values from 0 to 99 map to the years 1900 to 1999.
Patch for _makeDate method in lib/settings.js:
if (useLocal) {
const d = new Date(year, month - 1, day, hour, minute, second, fseconds);
if (0 < year < 100) {
d.setFullYear(year);
}
return d;
}
- Dominant language
- JavaScript
- Stars
- 2.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from oracle/node-oracledb
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
oracle/node-oracledb#1787 · 1 comment ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
oracle/node-oracledb#1788 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
oracle/node-oracledb#1785 · 2 comments ·
-
bug patch available
Difficulty 4/5 3-5 days Newbie friendliness 35/100
oracle/node-oracledb#1784 ·
-
bug patch available
Difficulty 4/5 3-5 days Newbie friendliness 48/100
oracle/node-oracledb#1782 · 7 comments ·
All issues in oracle/node-oracledb
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·