jewish-date
Version:
Converts Gregorian dates to Hebrew dates and vice versa.
3 lines (2 loc) • 1.17 kB
JavaScript
import{toLength as y}from"../numberUtils/numberUtils.js";var m=["yyyy","YYYY","yy","YY","MMMM","MM","M","dd","D","d"],M=()=>({d:t=>t.day.toString(),dd:t=>y(t.day,2),D:t=>t.day.toString(),M:t=>t.month.toString(),MM:t=>y(t.month,2),MMMM:t=>t.monthName,yy:t=>(t.year%100).toString().padStart(2,"0"),YY:t=>(t.year%100).toString().padStart(2,"0"),yyyy:t=>t.year.toString(),YYYY:t=>t.year.toString()}),T=(t,a,n)=>({d:e=>e.day.toString(),dd:e=>y(e.day,2),D:e=>t(e.day),M:e=>e.month.toString(),MM:e=>y(e.month,2),MMMM:e=>a(e.monthName),yy:e=>(e.year%100).toString().padStart(2,"0"),YY:e=>n(e.year),yyyy:e=>e.year.toString(),YYYY:e=>t(e.year)}),d=t=>{let a=[],n=0;for(;n<t.length;){let e=null;for(let r of m){let o=t.indexOf(r,n);if(o===n){e={token:r,index:o};break}}e?(a.push(e),n=e.index+e.token.length):n++}return a},g=(t,a,n)=>{let e=d(t),r="",o=0;for(let{token:i,index:s}of e)s>o&&(r+=t.slice(o,s)),r+=n[i](a),o=s+i.length;return o<t.length&&(r+=t.slice(o)),r},h="d MMMM yyyy",Y="D MMMM YYYY",k=M();export{h as DEFAULT_PATTERN,Y as DEFAULT_PATTERN_HEBREW,T as createHebrewFormatters,g as formatWithPattern,k as getEnglishFormatters};
//# sourceMappingURL=formatUtils.js.map