moment-rental
v1.0.0
Published
Fork of moment-business to support Saturdays and rental day breakdown
Downloads
2
Readme
moment-rental
Summary
Extends Moment.js to properly calculate the number of rental days between two given dates
Syntax: Add rental days to current date
moment().rentalAdd(days[, saturdays]);
Parameters
days (integer)
Number of rental days to add to current datesaturdays (BOOL)
Weather or not to include Saturdays
Syntax: Get rental day breakdown
moment(endDate).rentalDays(startDate[, saturdays]);
Parameters
endDate (moment object)
End date of rentalstartDate (moment object)
Start date of rentalsaturdays (BOOL)
Weather or not to include Saturdays
Installation
Install package
npm i moment-rental -S
Require in project
// ES5
var moment = require('moment');
require('moment-rental');
// ES6
import moment from 'moment';
import moment-rental;
Examples
Get new end date
moment('2015-02-04').rentalAdd(3).format('MM-DD-YYYY');
// 02-09-2015
Get new end date including Saturdays
moment('2015-02-04').rentalAdd(3, true).format('MM-DD-YYYY');
// 02-07-2015
Get rental day breakdown
moment('2015-02-12 08:00').rentalDays('2015-02-04 08:00');
// { Day: 0, FourWeek: 0, RentalDays: 6, Week: 1 }
Get rental day breakdown including Saturdays
moment('2015-02-12 08:00').rentalDays('2015-02-04 08:00', true);
// { Day: 0, FourWeek: 0, RentalDays: 7, Week: 1 }