UNPKG

@ppasmik/birth-number-utils

Version:

A TypeScript/JavaScript library for generating, validating, and parsing Czech and Slovak birth numbers (rodné číslo).

34 lines (33 loc) 1.43 kB
import { Gender } from '../types'; export declare function getRandomDateBetween90and18YearsAgo(): Date; export declare function getRandomGender(): Gender; export declare function formatDate(date: Date): string; export declare function paddingLeft(value: number, length?: number): string; export declare function paddingRight(value: number | string, paddingCount: number): string; export declare function addDelimeter(birthNumber: string): string; /** * Finds the nearest number divisible by 11 to a given input number. * * Mathematical Properties: * 1. For any real number x, returns y such that: * - y is divisible by 11 * - |x - y| ≤ |x - z| for any z divisible by 11 * 2. For equidistant cases: * - For positive numbers: chooses the larger value * - For negative numbers: chooses the smaller value * 3. Special cases: * - Returns 0 (positive zero) for inputs closest to zero * - Handles floating point imprecision using epsilon comparison * * Implementation Details: * - Uses epsilon (1e-10) for floating point comparison * - Employs floor and ceil for reliable quotient calculation * - Handles IEEE 754 floating point edge cases * * Time Complexity: O(1) * Space Complexity: O(1) * * @param {number} input - Any real number (floating point or integer) * @returns {number} The nearest number divisible by 11 */ export declare function nextNumberDivided11(input: number): number;