kodie / moment-holiday Goto Github PK
View Code? Open in Web Editor NEWA Moment.js plugin for handling holidays. NO LONGER MAINTAINED (DEPRECATED)
License: MIT License
A Moment.js plugin for handling holidays. NO LONGER MAINTAINED (DEPRECATED)
License: MIT License
I can't get any indication this plugin works with the latest or previous versions of moment.js. (I tried specifically using moment.js 2.0.0 as well as latest as of today).
Minimal case is:
<script src="js/moment.js"></script>
<script src="js/moment-holiday.js"></script>
<script>
var currentTime = moment();
console.log(currentTime); //Correct time shown
console.log('YOU: ' + currentTime.format("HH:mm DD-MM-YYYY")); //Correct time shown
var holiday = moment().isHoliday(null, true); //moment(...).isHoliday is not a function
</script>```
I'm having an issue when code is compiled and minified via gulp / browserify / babelify / gulp-uglify
Uncaught TypeError: Cannot read property 'united_states' of undefined, at:
p = function(t) { if (regions = t.split("/"), t = regions[0].toLowerCase().replace(" ", "_"), regions.shift(), !s.holidays[t]) try { var r = "./locale/"; "build" == n.split("/").slice(-1).pop() && (r = "." + r), e(r + t) } catch (s) {} return !!s.holidays[t] && (regions.length ? u(t, regions) : s.holidays[t]) }
in moment-holiday-us.min.js
It works fine with the same build process if I tell browserify not to minify via options, which skips gulp-uglify. Any thoughts on what could be going on?
I would be very nice to add French public holidays to the list of the available ones. Here's the full list of french public holidays : https://publicholidays.fr/2019-dates/
If you want me to make a PR, let me just know. ๐
In Berlin/Germany the 8th March is an officially legally holiday, please add Locale Germany/Berlin and International Women's Day
import holiday from "moment-holiday";
console.log(
holiday().holiday('Thanksgiving')._d,
holiday().holiday('Thanksgiving').isHoliday(),
holiday().holiday('Thanksgiving').isHoliday('Thanksgiving')
);
hi,
when I try to use is in angular, it gives me warning:
WARNING in ./node_modules/moment-holiday/build/moment-holiday-us.min.js
10:53-60 Critical dependency: require function is used in a way in which dependencies cannot be statically e
xtracted
WARNING in ./node_modules/moment-holiday/build/moment-holiday-us.min.js
6:3284-3296 Critical dependency: the request of a dependency is an expression
and when it's loaded in browser:
Uncaught TypeError: Cannot read property 'fn' of undefined
I'm new to js and typescript, so couldn't figure out a way to fix it. so if anyone could take a look would be awesome.
what I did in code is to test some functions:
import * as holidays from 'moment-holiday';
this.locales = holidays.load('united_kingdome');
Thanks!
The Canadian Thanksgiving is set in November, same date as the U.S. one. However, the actual Canadian thanksgiving is on the second week of October.
Looks like the library assumes that the Day After Thanksgiving is the 4th Friday of November based on this code:
moment-holiday/locale/united_states.js
Line 73 in 447e7ff
However, on years like 2019 when the first day of the month of November is Friday, this means that the code will actually calculate the day after Thanksgiving as being before Thanksgiving itself. To repro:
var momentHoliday = require("moment-holiday")
var moment = require('moment');
var newYears2019 = moment('2019 01 01', 'YYYY MM DD');
console.log(momentHoliday(newYears2019).holiday('Thanksgiving').format('YYYY MM DD'));
console.log(momentHoliday(newYears2019).holiday('Day After Thanksgiving').format('YYYY MM DD'));
Expected:
2019 11 28
2019 11 29
Actual:
2019 11 28
2019 11 22
I have problem with this error.
I use this library with moment.js and i'm tried to use moment-holiday because i want to check weekend and holiday in my project.so i'm install this libray and import to project and get this error how i fix it
Hi, I'm getting the following error:
ReferenceError: regions is not defined
at d (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:6:3117)
at Object.add (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:6:5870)
at Object.<anonymous> (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:16:116)
at Object.<anonymous> (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:16:138)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/app/current/bin/src/app/utils/cost/strategies/publicHoliday.strategy.js:5:1)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
Any idea why this is happening?
I'm using NodeJs v8.4.0 on AWS with typescript compiler.
The library is included as follows:
import * as moment from "moment";
import "moment-holiday";
The package cannot be imported in a Webpack setup: import moment from 'moment-holiday
yields Error: Cannot find module "."
. A require
calls does not succeed either. Could you add support for Webpack?
P.S. Originally discovered in the context of create-react-app
.
On client side when I call moment.modifyHolidays.set('Canada') and then log it with moment().holidays() it returns the default locale (us).
This only works server side. Is it possible to get it to work on client side?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.