Skip to content

Releases: p333ter/birth-number-utils

v2.0.7

17 Dec 14:23
Compare
Choose a tag to compare

Major enhancements to date handling and documentation:

  • Added support for string dates in ISO format (YYYY-MM-DD)
  • Fixed month calculation issues with JavaScript Date
  • Added clear documentation about date handling differences
  • Improved examples with detailed month handling explanations

Release Description

🎉 New Features

  • Added support for string dates in birth number generation (e.g., '1985-11-19')
  • Enhanced documentation with clear examples of date handling

🔨 Fixed

  • Corrected month calculation when using JavaScript Date objects
  • Fixed inconsistencies between string and Date object inputs

📚 Documentation

  • Added detailed explanation of date handling differences between string and Date formats
  • Updated examples to show recommended date input methods
  • Added warning notes about JavaScript Date's 0-based months

🔍 Technical Details

The birth number generator now:

  • Accepts both Date objects and ISO format strings
  • Properly handles month calculations regardless of input format
  • Maintains backwards compatibility with existing APIs
  • Uses dayjs for consistent date processing

💡 Usage Examples

// Recommended (string format)
generateBirthNumber({ 
 birthDate: '1985-11-19'  // November 19, 1985
})

// Legacy (Date object)
generateBirthNumber({ 
 birthDate: new Date(1985, 10, 19)  // Also November 19, 1985
})

v2.0.6

17 Dec 10:56
Compare
Choose a tag to compare

Release Description

🔨 Fixed

  • Birth numbers with month '00' are now properly rejected
  • Future dates are now correctly handled - possible but not valid
  • Birth number validation now properly follows the original specification where:
  • isPossible() checks only format validity
  • isValid() adds extra validation for future dates

🧪 Testing

  • Added tests for zero month validation
  • Updated future date tests to match correct validation pattern
  • Added tests to verify isPossible/isValid behavior for future dates

🔍 Technical Details

The validation logic has been refined to:

  • Reject invalid months (00) during initial parsing
  • Allow parsing of future dates but mark them as invalid

Release description (v2.0.0)

16 Dec 23:35
Compare
Choose a tag to compare

Major Release: Enhanced Birth Number Handling

🎉 New Features

  • BirthNumber Class: New object-oriented approach to handle birth numbers
  • Enhanced Parsing: More detailed information from parsed birth numbers
  • Age Calculations: Added methods to calculate age and check adulthood
  • Improved Validation: More robust validation with detailed error reporting
  • Factory Function: New rodnecislo() function for easier instantiation

💡 Improvements

  • Better handling of formatted (with slash) and raw birth numbers
  • Consistent sanitization across all functions
  • Enhanced type safety with TypeScript
  • Comprehensive test coverage for all new features

🔨 Breaking Changes

  • parseBirthNumber now returns an extended object with additional properties
  • Updated TypeScript interfaces for new return types

📝 Example Usage

import { rodnecislo } from '@ppasmik/birth-number-utils';

const rc = rodnecislo('900720/3117');

rc.isMale()             // Check gender
rc.birthDateAsString()  // Get formatted date
rc.age()               // Get current age
rc.isAdult()           // Check if person is adult
rc.isValid()           // Validate birth number

📦 Migration Guide

If you're using the basic functions (generateCzechBirthNumber, generateSlovakBirthNumber, isValidBirthNumber), no changes are required. For parseBirthNumber, update your code to handle the new return type with additional properties.

v1.0.1

16 Dec 21:11
Compare
Choose a tag to compare
updated readme

v1.0.0

16 Dec 21:01
Compare
Choose a tag to compare

First Release: @ppasmik/birth-number-utils v1.0.0

We are excited to announce the first release of @ppasmik/birth-number-utils, a TypeScript/JavaScript library designed to generate and validate Czech and Slovak birth numbers (rodné číslo).

Features

  • Birth Number Generators: Generate valid Czech and Slovak birth numbers with customizable options like gender, date of birth, and format.
  • Validation: Validate birth numbers for format, modulo 11 compliance, and real dates.
  • Parsing: Extract meaningful information such as gender and birth date from a valid birth number.
  • Full TypeScript Support: Includes type definitions for seamless integration.
  • Lightweight: Utilizes dayjs for efficient and lightweight date handling.

Highlights

  • Main Functions:

    • isValidBirthNumber: Quickly validate a birth number.
    • parseBirthNumber: Parse a birth number to retrieve the birth date and gender.
    • generateCzechBirthNumber: Generate valid Czech birth numbers.
    • generateSlovakBirthNumber: Generate valid Slovak birth numbers.
  • Flexible: Supports both formatted (955123/1234) and raw (9551231234) birth number formats.

  • Robust Validation: Ensures compliance with both Czech and Slovak laws, including leap years and historical exceptions.

Installation

npm install @ppasmik/birth-number-utils