UNPKG

nhb-toolbox

Version:

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

10 lines (9 loc) 465 B
import { isPalindrome } from '../../string/guards.js'; /** * Plugin to inject `isPalindromeDate` method */ export const palindromePlugin = (ChronosClass) => { ChronosClass.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); }; };