dutyhours
Version:
A tool to calculate total working hours in a given month, taking into account public holidays and configurable working days.
3 lines • 4.48 kB
JavaScript
;var w=Object.create;var h=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var D=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!x.call(e,o)&&o!==n&&h(e,o,{get:()=>t[o],enumerable:!(i=b(t,o))||i.enumerable});return e};var j=(e,t,n)=>(n=e!=null?w(k(e)):{},D(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e));var y=j(require("date-holidays"),1),v=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function S(e,t){let n=v[e];return t[`without${n}s`]?!1:t[`with${n}s`]?!0:e>=1&&e<=5}function M(e,t,n){let i=new y.default(n),o=new Date(e,t-1,1),a=new Date(e,t,0);return new Set(i.getHolidays(e).filter(({date:r,type:c})=>{let l=new Date(r);return l>=o&&l<=a&&c!=="observance"}).map(({date:r})=>new Date(r).toDateString()))}function O(e){let t=new Date,{country:n,hoursPerDay:i=8,month:o=t.getMonth()+1,year:a=t.getFullYear()}=e,r=M(a,o,n),c=new Date(a,o,0),l=0;for(let u=1;u<=c.getDate();u++){let m=new Date(a,o-1,u),p=m.getDay();!r.has(m.toDateString())&&S(p,e)&&(l+=i)}return l}var g=O;var s=require("commander");var d={name:"dutyhours",version:"1.0.5",description:"A tool to calculate total working hours in a given month, taking into account public holidays and configurable working days.",keywords:["working-hours"],bugs:{url:"https://github.com/kamdz/dutyhours/issues"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/kamdz/dutyhours.git"},license:"MIT",author:{name:"Kamil Dzwonkowski",email:"npm@kamdz.dev",url:"https://github.com/kamdz"},type:"module",exports:{".":{import:"./dist/index.js",require:"./dist/index.cjs"}},main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",bin:"./dist/cli.js",files:["dist","package.json","README.md","CHANGELOG.md","LICENSE"],scripts:{build:"tsup",cli:"tsx bin/cli.ts",commit:"cz",dev:"tsx watch src/index.ts",dx:"npx @kamdz/dx",format:"prettier --write --ignore-unknown .",lint:"eslint . --fix","lint-staged":"lint-staged",prepare:"husky",start:"tsx src/index.ts",test:"jest --coverage --passWithNoTests","type-check":"tsc --noEmit"},"lint-staged":{"**/*.{ts,tsx,js,jsx,cjs,mjs,}":["eslint --fix"],"**/*.{ts,tsx,js,jsx,json,md,cjs,mjs,yml,yaml}":["prettier --write --ignore-unknown"]},config:{commitizen:{path:"./node_modules/cz-conventional-changelog"}},release:{branches:["main"],plugins:["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator",["@semantic-release/changelog",{changelogFile:"CHANGELOG.md"}],"@semantic-release/npm",["@semantic-release/git",{assets:["package.json","CHANGELOG.md"],message:"chore(release): ${nextRelease.version} \n\n${nextRelease.notes}"}],"@semantic-release/github"]},devDependencies:{"@commitlint/cli":"^19.6.1","@commitlint/config-conventional":"^19.6.0","@eslint/compat":"^1.2.5","@eslint/js":"^9.19.0","@ianvs/prettier-plugin-sort-imports":"^4.4.1","@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@types/fs-extra":"^11.0.4","@types/jest":"^29.5.14","@types/node":"^22.10.10",commitizen:"^4.3.1","cz-conventional-changelog":"^3.3.0",eslint:"^9.19.0","eslint-config-prettier":"^10.0.1","eslint-plugin-import":"^2.31.0","eslint-plugin-prettier":"^5.2.3",globals:"^15.14.0",husky:"^9.1.7",jest:"^29.7.0","lint-staged":"^15.4.3",prettier:"3.4.2","semantic-release":"^24.2.1","ts-jest":"^29.2.5",tsup:"^8.3.6",tsx:"^4.19.2",typescript:"^5.7.3","typescript-eslint":"^8.21.0"},packageManager:"yarn@4.5.1",dependencies:{commander:"^13.1.0","date-holidays":"^3.23.21"}};s.program.version(d.version).description(d.description).argument("<country>","The country code to determine the public holidays").option("-h, --hours","The number of working hours in a single working day").option("-m, --month <month>","The month (indexed from 1 to 12) to calculate working hours for. Defaults to the current month").option("-y, --year <year>","The year to calculate working hours for. Defaults to the current year").action((e,t)=>{console.log(g({country:e,...t}))});["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].forEach(e=>{s.program.addOption(new s.Option(`--with${e}s`,`Whether to include ${e}s as working days`)),s.program.addOption(new s.Option(`--without${e}s`,`Whether to exclude ${e}s from working days`))});s.program.parse(process.argv);
//# sourceMappingURL=cli.cjs.map