UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

9 lines (8 loc) 405 B
import { isPalindrome } from '../../string/guards.js'; export const palindromePlugin = ($Chronos) => { $Chronos.prototype.isPalindromeDate = function (shortYear = false) { const padded = this.formatStrict(shortYear ? 'YY-MM-DD' : 'YYYY-MM-DD'); const normal = this.formatStrict(shortYear ? 'YY-M-D' : 'YYYY-M-D'); return isPalindrome(padded) || isPalindrome(normal); }; };