import{n as e,r as t,t as n}from"./chunk-74CEPOFO-V0JXh91S.mjs";var r={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`]},i=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],a=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function o(e,t=2){return String(e).padStart(t,`0`)}function s(e,t,n){let r={Y:e.getUTCFullYear(),m:e.getUTCMonth(),D:e.getUTCDate(),H:e.getUTCHours(),M:e.getUTCMinutes(),S:e.getUTCSeconds(),w:e.getUTCDay()},s=``,c=0;for(;c<t.length;){if(t[c]===`%`&&c+1<t.length){let n=t[++c];switch(n){case`%`:s+=`%`;break;case`a`:s+=i[r.w];break;case`b`:case`h`:s+=a[r.m];break;case`d`:s+=o(r.D);break;case`e`:s+=String(r.D).padStart(2,` `);break;case`F`:s+=`${r.Y}-${o(r.m+1)}-${o(r.D)}`;break;case`H`:s+=o(r.H);break;case`I`:s+=o(r.H%12||12);break;case`m`:s+=o(r.m+1);break;case`M`:s+=o(r.M);break;case`n`:s+=`
`;break;case`p`:s+=r.H<12?`AM`:`PM`;break;case`P`:s+=r.H<12?`am`:`pm`;break;case`R`:s+=`${o(r.H)}:${o(r.M)}`;break;case`s`:s+=Math.floor(e.getTime()/1e3);break;case`S`:s+=o(r.S);break;case`t`:s+=`	`;break;case`T`:s+=`${o(r.H)}:${o(r.M)}:${o(r.S)}`;break;case`u`:s+=r.w||7;break;case`w`:s+=r.w;break;case`y`:s+=o(r.Y%100);break;case`Y`:s+=r.Y;break;case`z`:s+=`+0000`;break;case`Z`:s+=`UTC`;break;default:s+=`%${n}`}}else s+=t[c];c++}return s}function c(e){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t;if(/^\d+$/.test(e))return new Date(Number.parseInt(e,10)*1e3);let n=e.toLowerCase();return n===`now`||n===`today`?new Date:n===`yesterday`?new Date(Date.now()-864e5):n===`tomorrow`?new Date(Date.now()+864e5):null}var l={name:`date`,async execute(i,a){if(n(i))return t(r);let o=!1,l=null,u=null,d=!1,f=!1;for(let t=0;t<i.length;t++){let n=i[t];if(n===`-u`||n===`--utc`)o=!0;else if(n===`-d`||n===`--date`)l=i[++t]??``;else if(n.startsWith(`--date=`))l=n.slice(7);else if(n===`-I`||n===`--iso-8601`)d=!0;else if(n===`-R`||n===`--rfc-email`)f=!0;else if(n.startsWith(`+`))u=n.slice(1);else{if(n.startsWith(`--`))return e(`date`,n);if(n.startsWith(`-`))for(let t of n.slice(1))if(t===`u`)o=!0;else if(t===`I`)d=!0;else if(t===`R`)f=!0;else return e(`date`,`-${t}`)}}let p=l===null?new Date:c(l);if(!p)return{stdout:``,stderr:`date: invalid date '${l}'
`,exitCode:1};let m;return m=u?s(p,u,o):d?s(p,`%Y-%m-%dT%H:%M:%S%z`,o):f?s(p,`%a, %d %b %Y %H:%M:%S %z`,o):s(p,`%a %b %e %H:%M:%S %Z %Y`,o),{stdout:`${m}
`,stderr:``,exitCode:0}}},u={name:`date`,flags:[{flag:`-d`,type:`value`,valueHint:`string`},{flag:`-u`,type:`boolean`},{flag:`-I`,type:`boolean`},{flag:`-R`,type:`boolean`}]};export{l as n,u as t};
//# sourceMappingURL=chunk-D7MEQ3VN-BM_kIbvf.mjs.map