quattro-stagioni v0.1.0
quattro-stagioni
quattro-stagioni is a JavaScript library (pure vanilla ES6) that returns the current season for a given date.
It can also add the current season as CSS class to an HTML DOM element, e.g. to the body
.
Think modernizr for seasons.
Usage
npm install --save quattro-stagioni
And in you code:
import { QuattroStagioni } from './index.js';
let qs = new QuattroStagioni()
qs.update() // will add a class 'winter', 'spring', 'summer' or 'autumn' to the <body> tag
See src/example.html for a full example.
Options
There are a few options available in this library.
Change the hemisphere
import { Location, QuattroStagioni } from './index.js';
let locN = Location.NORTHERN_HEMISPHERE
let locS = Location.SOUTHERN_HEMISPHERE
let qsN = new QuattroStagioni(locN)
let qsS = new QuattroStagioni(locS)
console.log(qsN.meteorologicalSeason(), qsS.meteorologicalSeason())
Specific Date
import { QuattroStagioni } from './index.js';
let today = new Date() // change to any date you wish
let qs = new QuattroStagioni()
console.log(qs.meteorologicalSeason(today))
console.log(qs.update(today))
Data Basis
This library works based on the dates reported on the Season page of Wikipedia, the free encyclopedia.
Currently this library only supports meteorological seasons.
The Meaning of Quattro Stagioni
It's Italian and means Four Seasons. Also, it's the name of a delicious type of pizza.
Development
To work on the example.html
, run the simple development server:
grunt connect
Then connect to http://localhost:8000/example.html
.
Contributions
Contributions are welcome. Please open a PR where you describe your contribution.
Make sure that jshint
does not report any errors.
All contributions have to be made available under the same terms as this project, i.e. under the terms of the Creative Commons Zero license.
License
This code is in public domain.
To the extent possible under law, the authors have waived all copyright and related or neighboring rights to quattro-stagioni.
4 years ago