3.0.3 • Published 5 months ago

prod-cal v3.0.3

Weekly downloads
7
License
MIT
Repository
github
Last release
5 months ago

Production Calendar

codecov codacy version license

..::Live demo::..

Installation

npm i prod-cal

Usage

Production Calendar

const Calendar = require("prod-cal")

//'ru' - locale
let calendar = new Calendar("ru")

//Will print 'holiday'
console.log(calendar.getDay(2019, 1, 27))
console.log(calendar.getDate(new Date("2019-01-27")))

//Will print 'work'
console.log(calendar.getDay(2019, 1, 28))
console.log(calendar.getDate(new Date("2019-01-28")))

//Will print 'work_reduced'
console.log(calendar.getDay(2019, 2, 22))
console.log(calendar.getDate(new Date("2019-22-22")))

//Will print '20'
console.log(calendar.getMonth(2019, 2).filter(d => d.indexOf("work") >= 0).length)

//Will print '248'
console.log(calendar.getYear(2020).map(m => m.filter(d => d.indexOf("work") >= 0).length).reduce((a, c) => a + c, 0))

Timesheet Builder

const TimesheetBuilder = require("prod-cal").TimesheetBuilder

//'ru' - locale
let timesheetBuilder = new TimesheetBuilder("ru")

//Will print '{days: 21, hours: 167}'
const timesheet = timesheetBuilder.build(new Date("2023-11-1"), new Date("2023-11-30"), [])
console.log(timesheet.summary)

//Will print '{days: 64, hours: 511}'
const actual = timesheetBuilder.build(new Date("2023-9-18"), new Date("2023-12-15"), [])
console.log(timesheet.summary)

//Will print '{days: 16, hours: 127}'
const timesheet = timesheetBuilder.build(new Date("2023-11-1"), new Date("2023-11-30"), [
	{date: new Date(2023, 11-1, 20), hours: 0},
	{date: new Date(2023, 11-1, 21), hours: 0},
	{date: new Date(2023, 11-1, 22), hours: 0},
	{date: new Date(2023, 11-1, 23), hours: 0},
	{date: new Date(2023, 11-1, 24), hours: 0}
])
console.log(timesheet.summary)
3.0.3

5 months ago

3.0.2

5 months ago

2.0.3

5 months ago

3.0.1

5 months ago

2.0.2

12 months ago

2.0.1

1 year ago

2.0.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago