Coder Social home page Coder Social logo

moment-business's Issues

How do i use it?

var final = moment(date).weekDays(date2); if like this it isn't working

Add holidays

I know that holidays varies by country, state, city, province, etc

I think would be good have a way to set the holidays, with a array of month/date

For instance with the US federal holidays would be something like this moment.setHolidays(['January 01', 'January 18', 'February 15', 'July 04', 'May 30', 'September 5', 'October 10', 'November 11', 'November 26', 'December 26'])

For NY we would push some more days to the list: moment.addHolidays(['February 12', 'November 08', 'December 25'])

Them when we use methods of moment-bussiness it consider these days not as weekdays, and not as weekendDays.

We can also create methods to count holidays.

What do you think?

Using without npm

I tried to use the lib without npm,
by copying the moment-business.js file,
and source it with:
<script src="moment-business.js"></script>

then use it with
import business from 'moment-business';

but I got error below:
Uncaught SyntaxError: Cannot use import statement outside a module

Any idea how to solve this ?

Moment Timezone support

When I try to use this with moment timezone in typescript, it looks like both timezone and business have definition to the Moment but they can't convert to each other.

Update the library

It's been a few years since I wrote this, but it's my most popular library by downloads. I should update it!

  1. Update to the latest Node
  2. Fix builds
  3. Modernize the repository

This won't involve any code changes, and no npm releases. It'll simply be a repository refresher.

integrate with moment prototype

would be a lot easier (and cleaner) if you would implement the method through the prototype.

moment().isWeekend() is much nicer then bussiness.isWeekend(moment())

Fix browser export for non-module loader environments

It seems to currently be exporting as window.none. Note that this only affects users who aren't using a module bundler like CJS, AMD, or ES2015 modules. If you are using those module bundlers, then you're good to go.

weekendDays sometimes incorrect

The following code returns an incorrect value for the number of weekend days:

const start = moment.utc("2016-07-25T13:43:00.000+00:00");
const end = moment.utc("2016-08-22T11:28:00.000+00:00");
business.weekendDays(start, end); // returns 7, expected 8

Is this right?

Introduce floating point precision.

Often times when calculating week days I'd like more precision to be returned. Currently calculations less then one day get rounded down to zero. I would like to see a flag introduced to signal when to not round down. So we end up with possible values of 0.5 days or 7.3 days.

off-by-one error on weekDays (maybe due to moment#diff)

Seems like there is a problem at moment#diff, used by the weekDays method.

You can reproduce the same bug on moment-business with these tests: https://github.com/jmeas/moment-business/compare/jmeas:master...leobalter:return-proper-weekdays?expand=1

I didn't open a PR with these tests as they're not following the standard from the other tests, we could improve it.

I checked the return from the .diff call at weekDays and the off-by-one is happening there.

O(n)!

O(n) => O(1)

  • Add constant time addition
  • Add constant time subtraction

Clarify documentation for weekDays / weekendDays

Please can you make the documentation in the README clearer for using weekDays and weekendDays - please make it specific that these have to be used endMoment.weekDays(startMoment)

Just been using this with startMoment.weekDays(endMoment) and puzzling over weird responses - it was only when I looked at the source that I realised what was going on.

Calculation problem if the endDate is weekend

When using the weekDays function,

The result may + 1 day when the startMoment and endMoment are both weekend AND when the endMoment is weekend.

Here are some testing results:

console.log(momentBusiness.weekDays(moment('08-05-2016','DD-MM-YYYY'),moment('15-05-2016','DD-MM-YYYY')));
// Actual Result = 5, Expected Result = 4

console.log(momentBusiness.weekDays(moment('09-05-2016','DD-MM-YYYY'),moment('14-05-2016','DD-MM-YYYY')))
// Actual Result = 5, Expected Result = 4

console.log(momentBusiness.weekDays(moment('07-05-2016','DD-MM-YYYY'),moment('13-05-2016','DD-MM-YYYY')))
// Actual Result = 4, Expected Result = 4 <-- This is correct

Move away from moment plugins

@cowboy mentioned that there's not much reason for this to modify the moment obj. directly. I should just expose methods on an obj rather than modifying the moment prototype.

Undefined is not a function

When I do today.workDays( tomorrow ) where today and tomorrow are moments a day apart, I get Undefined is not a function - is there something I am doing wrong?

.addWorkDays() and .subtractWorkDays() are working fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.