Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

month

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

month - npm Package Compare versions

Comparing version
1.0.0
to
2.0.0
+24
LICENSE
The MIT License (MIT)
Copyright (c) 2015 Jon Schlinkert.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
+23
-12

@@ -7,8 +7,2 @@ # {%= name %} {%= badge("fury") %}

## Run tests
```bash
npm test
```
## Usage

@@ -20,9 +14,21 @@

month();
//=> 'December' (current month)
//=> 'January' (current month full name)
month('December');
//=> '12'
month('M');
//=> '1' (current month number)
month('MM');
//=> '01' (current month number, zero-filled)
month('MMM');
//=> 'Jan' (current month abbreviation)
month('MMMM');
//=> 'January' (current month full name)
month('January');
//=> '12' (number of the given month number)
month(1);
//=> 'January'
//=> 'January' (name of the given month number)

@@ -33,4 +39,10 @@ month(2);

## Related projects
{%= related(['year', 'month', 'months', 'days', 'seconds', 'weekday', 'iso-week', 'week', 'o-clock'], {remove: name}) %}
## Running tests
{%= include("tests") %}
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %})
{%= include("contributing") %}

@@ -47,2 +59,1 @@ ## Author

{%= include("footer") %}
+21
-10
/**
* month <https://github.com/jonschlinkert/month>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Copyright (c) 2015 Jon Schlinkert.
* Licensed under the MIT license.
*/
var repeat = require('repeat-string');
var isNumber = require('is-number');
var months = require('months');
module.exports = function month(num) {
module.exports = function month(val) {
var mo = new Date().getMonth();
if (typeof num === 'undefined') {
if (typeof val === 'undefined') {
return mo;
}
if (isNumber(+num)) {
return months[num - 1];
// moment conventions
if (typeof val === 'string') {
if (val === 'M') {
return mo;
}
if (val === 'MM') {
return repeat('0', 2 - String(mo).length) + mo;
}
if (val === 'MMM') {
return months.abbr[mo];
}
if (val === 'MMMM') {
return months[mo];
}
}
if (typeof num !== 'string') {
throw new Error('[months] expects a string or number, but got: ' + num);
if (isNumber(+val)) {
return months[val - 1];
}
return months.indexOf(num) + 1;
return months.indexOf(val) + 1;
};
{
"name": "month",
"description": "Get the name or number of the current month or any month of the year.",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/jonschlinkert/month",

@@ -19,18 +19,18 @@ "author": {

"type": "MIT",
"url": "https://github.com/jonschlinkert/month/blob/master/LICENSE-MIT"
"url": "https://github.com/jonschlinkert/month/blob/master/LICENSE"
},
"main": "index.js",
"engines": {
"node": ">=0.8"
"node": ">=0.10"
},
"scripts": {
"test": "mocha -R spec"
"test": "mocha"
},
"dependencies": {
"is-number": "^0.1.1",
"months": "^0.1.0"
"is-number": "^2.0.2",
"months": "^1.0.0",
"repeat-string": "^1.5.2"
},
"devDependencies": {
"mocha": "*",
"should": "*"
"mocha": "*"
},

@@ -46,2 +46,2 @@ "keywords": [

]
}
}
+46
-20

@@ -5,14 +5,8 @@ # month [![NPM version](https://badge.fury.io/js/month.svg)](http://badge.fury.io/js/month)

## Install with [npm](npmjs.org)
Install with [npm](https://www.npmjs.com/)
```bash
npm i month --save
```sh
$ npm i month --save
```
## Run tests
```bash
npm test
```
## Usage

@@ -24,9 +18,21 @@

month();
//=> 'December' (current month)
//=> 'January' (current month full name)
month('December');
//=> '12'
month('M');
//=> '1' (current month number)
month('MM');
//=> '01' (current month number, zero-filled)
month('MMM');
//=> 'Jan' (current month abbreviation)
month('MMMM');
//=> 'January' (current month full name)
month('January');
//=> '12' (number of the given month number)
month(1);
//=> 'January'
//=> 'January' (name of the given month number)

@@ -37,19 +43,39 @@ month(2);

## Related projects
* [days](https://github.com/jonschlinkert/days): Days of the week.
* [iso-week](https://github.com/jonschlinkert/iso-week): Get the ISO week of the year.
* [months](https://github.com/jonschlinkert/months): Months of the year.
* [o-clock](https://github.com/jonschlinkert/o-clock): Simple utility for displaying the time in 12-hour clock format.
* [seconds](https://github.com/jonschlinkert/seconds): Get the number of seconds for a minute, hour, day and week.
* [weekday](https://github.com/jonschlinkert/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/jonschlinkert/weekday)
* [week](https://github.com/jonschlinkert/week): Get the current week number.
* [year](https://github.com/jonschlinkert/year): Simple utility to get the current year with 2 or 4 digits.
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/month/issues)
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/month/issues/new)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb](https://github.com/assemble/verb) on December 06, 2014. To update, run `npm i -g verb && verb`._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 25, 2015._
+55
-29

@@ -10,45 +10,71 @@ /**

var should = require('should');
/* deps: mocha */
var assert = require('assert');
var months = require('months');
var repeat = require('repeat-string');
var month = require('./');
describe('patterns', function () {
it('should return the current month number', function () {
assert.equal(typeof month('M') === 'number', true);
assert.equal(month('M'), new Date().getMonth(), true);
});
it('should zero-fill the current month number', function () {
assert.equal(typeof month('MM') === 'string', true);
var mo = new Date().getMonth();
var res = repeat('0', 2 - String(mo).length) + mo;
assert.equal(month('MM'), res, true);
});
it('should return the current month abbreviation', function () {
assert.equal(typeof month('MMM') === 'string', true);
assert.equal(month('MMM'), months.abbr[new Date().getMonth()], true);
});
it('should return the current full month name', function () {
assert.equal(typeof month('MMMM') === 'string', true);
assert.equal(month('MMMM'), months[new Date().getMonth()], true);
});
});
describe('month()', function () {
it('should return an object with the number and name of the current month', function () {
month().should.equal(new Date().getMonth());
assert.equal(month(), new Date().getMonth(), true);
});
it('should return the current month name', function () {
month(12).should.be.a.string;
assert.equal(typeof month(12) === 'string', true);
});
it('should return the current month number', function () {
month('December').should.be.a.number;
assert.equal(typeof month('December') === 'number', true);
});
it('should return the given month', function () {
month(1).should.equal('January');
month(2).should.equal('February');
month(3).should.equal('March');
month(4).should.equal('April');
month(5).should.equal('May');
month(6).should.equal('June');
month(7).should.equal('July');
month(8).should.equal('August');
month(9).should.equal('September');
month(10).should.equal('October');
month(11).should.equal('November');
month(12).should.equal('December');
assert.equal(month(1), 'January', true);
assert.equal(month(2), 'February', true);
assert.equal(month(3), 'March', true);
assert.equal(month(4), 'April', true);
assert.equal(month(5), 'May', true);
assert.equal(month(6), 'June', true);
assert.equal(month(7), 'July', true);
assert.equal(month(8), 'August', true);
assert.equal(month(9), 'September', true);
assert.equal(month(10), 'October', true);
assert.equal(month(11), 'November', true);
assert.equal(month(12), 'December', true);
});
it('should return the given number', function () {
month('January').should.equal(1);
month('February').should.equal(2);
month('March').should.equal(3);
month('April').should.equal(4);
month('May').should.equal(5);
month('June').should.equal(6);
month('July').should.equal(7);
month('August').should.equal(8);
month('September').should.equal(9);
month('October').should.equal(10);
month('November').should.equal(11);
month('December').should.equal(12);
assert.equal(month('January'), 1, true);
assert.equal(month('February'), 2, true);
assert.equal(month('March'), 3, true);
assert.equal(month('April'), 4, true);
assert.equal(month('May'), 5, true);
assert.equal(month('June'), 6, true);
assert.equal(month('July'), 7, true);
assert.equal(month('August'), 8, true);
assert.equal(month('September'), 9, true);
assert.equal(month('October'), 10, true);
assert.equal(month('November'), 11, true);
assert.equal(month('December'), 12, true);
});
});
});

Sorry, the diff of this file is not supported yet