From 99ec25bbb6f410ae33f09ee75ae005f5ffcdffcf Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Sun, 11 Jun 2023 22:47:41 +0200 Subject: Update the docs which incorrectly had a 1-indexed month --- README.md | 4 ++-- south-african-id-parser.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2efa08e..fc5517a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ var validIdNumber = '9001049818080'; var info = saIdParser.parse(validIdNumber); // info === { // isValid: true, -// dateOfBirth: new Date(1990, 01, 04), +// dateOfBirth: new Date(1990, 0, 4), // isMale: true, // isFemale: false, // isSouthAfricanCitizen: true @@ -95,7 +95,7 @@ var saIdParser = require('south-african-id-parser'); var validIdNumber = '9001049818080'; var dateOfBirth = saIdParser.parseDateOfBirth(validIdNumber); -// dateOfBirth === new Date(1990, 01, 04) +// dateOfBirth === new Date(1990, 0, 4) ``` The date of birth included in the ID number has a two digit year. For diff --git a/south-african-id-parser.js b/south-african-id-parser.js index 62f5e15..983647a 100644 --- a/south-african-id-parser.js +++ b/south-african-id-parser.js @@ -52,7 +52,7 @@ * var info = saIdParser.parse(validIdNumber); * // info === { * // isValid: true, - * // dateOfBirth: new Date(1990, 01, 04), + * // dateOfBirth: new Date(1990, 0, 4), * // isMale: true, * // isFemale: false, * // isSouthAfricanCitizen: true @@ -103,6 +103,9 @@ * December 2015. If, on the other hand, the date of birth is parsed as 11 * December 15, that will be interpreted as 10 December 1915. * + * The date will be in the local timezone, with the time portion set to + * midnight. + * * @function * @param {string} idNumber - The ID number to be parsed. * @return {?Date} The date of birth from the ID number, or undefined if the @@ -114,7 +117,7 @@ * var validIdNumber = '9001049818080'; * var dateOfBirth = saIdParser.parseDateOfBirth(validIdNumber); * - * // dateOfBirth === new Date(1990, 01, 04) + * // dateOfBirth === new Date(1990, 0, 4) */ parseDateOfBirth: parseDateOfBirth, -- cgit v1.2.3