import{a as m,b as p,c as g}from"./chunk-74CEPOFO.js";var k={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING   display time described by STRING","-u, --utc           print Coordinated Universal Time (UTC)","-I, --iso-8601      output date/time in ISO 8601 format","-R, --rfc-email     output RFC 5322 date format","    --help          display this help and exit"]},M=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function n(t,i=2){return String(t).padStart(i,"0")}function T(t){let i=-t.getTimezoneOffset();return`${i>=0?"+":"-"}${n(Math.floor(Math.abs(i)/60))}${n(Math.abs(i)%60)}`}function d(t,i,r){let a=r?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},e="",o=0;for(;o<i.length;){if(i[o]==="%"&&o+1<i.length){let l=i[++o];switch(l){case"%":e+="%";break;case"a":e+=M[a.w];break;case"b":case"h":e+=h[a.m];break;case"d":e+=n(a.D);break;case"e":e+=String(a.D).padStart(2," ");break;case"F":e+=`${a.Y}-${n(a.m+1)}-${n(a.D)}`;break;case"H":e+=n(a.H);break;case"I":e+=n(a.H%12||12);break;case"m":e+=n(a.m+1);break;case"M":e+=n(a.M);break;case"n":e+=`
`;break;case"p":e+=a.H<12?"AM":"PM";break;case"P":e+=a.H<12?"am":"pm";break;case"R":e+=`${n(a.H)}:${n(a.M)}`;break;case"s":e+=Math.floor(t.getTime()/1e3);break;case"S":e+=n(a.S);break;case"t":e+="	";break;case"T":e+=`${n(a.H)}:${n(a.M)}:${n(a.S)}`;break;case"u":e+=a.w||7;break;case"w":e+=a.w;break;case"y":e+=n(a.Y%100);break;case"Y":e+=a.Y;break;case"z":e+=r?"+0000":T(t);break;case"Z":e+=r?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:e+=`%${l}`}}else e+=i[o];o++}return e}function S(t){let i=new Date(t);if(!Number.isNaN(i.getTime()))return i;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let r=t.toLowerCase();return r==="now"||r==="today"?new Date:r==="yesterday"?new Date(Date.now()-864e5):r==="tomorrow"?new Date(Date.now()+864e5):null}var w={name:"date",async execute(t,i){if(p(t))return m(k);let r=!1,a=null,e=null,o=!1,l=!1;for(let f=0;f<t.length;f++){let s=t[f];if(s==="-u"||s==="--utc")r=!0;else if(s==="-d"||s==="--date")a=t[++f]??"";else if(s.startsWith("--date="))a=s.slice(7);else if(s==="-I"||s==="--iso-8601")o=!0;else if(s==="-R"||s==="--rfc-email")l=!0;else if(s.startsWith("+"))e=s.slice(1);else{if(s.startsWith("--"))return g("date",s);if(s.startsWith("-"))for(let b of s.slice(1))if(b==="u")r=!0;else if(b==="I")o=!0;else if(b==="R")l=!0;else return g("date",`-${b}`)}}let u=a!==null?S(a):new Date;if(!u)return{stdout:"",stderr:`date: invalid date '${a}'
`,exitCode:1};let c;return e?c=d(u,e,r):o?c=d(u,"%Y-%m-%dT%H:%M:%S%z",r):l?c=d(u,"%a, %d %b %Y %H:%M:%S %z",r):c=d(u,"%a %b %e %H:%M:%S %Z %Y",r),{stdout:`${c}
`,stderr:"",exitCode:0}}},H={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"}]};export{w as a,H as b};
