Socket
Socket
Sign inDemoInstall

date-and-time

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-and-time - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

.eslintrc

15

package.json
{
"name": "date-and-time",
"version": "0.1.6",
"version": "0.1.7",
"description": "Date and time utilities for Node.js and browser",
"main": "src/date-and-time.js",
"main": "date-and-time.js",
"scripts": {
"test": "node ./node_modules/jasmine-node/lib/jasmine-node/cli.js ./spec",
"compile": "./node_modules/gulp/bin/gulp.js compile"
"test": "mocha test/test.js && mocha-phantomjs test/test.html",
"compile": "./compile"
},

@@ -30,7 +30,6 @@ "repository": {

"devDependencies": {
"gulp": "^3.8.10",
"gulp-closure-compiler-service": "^0.5.0",
"gulp-rename": "^1.2.0",
"jasmine-node": "^1.14.5"
"expect.js": "^0.3.1",
"mocha": "^2.2.4",
"mocha-phantomjs": "^3.5.3"
}
}
# date-and-time [![Circle CI](https://circleci.com/gh/knowledgecode/date-and-time.svg?style=svg)](https://circleci.com/gh/knowledgecode/date-and-time)
Date and time utilities for Node.js and browser.
This is a date and time utility for Node.js and browser.
## WHY
Probably the most famous date library is [Moment.js](http://momentjs.com/). That is so great but has been bloated (11.3k gz). We require a simpler one than that.
Probably the most famous date library is [Moment.js](http://momentjs.com/). That is so great but has been bloated (12k gz). This will be good solution if you are good enough the most basic function and require a small tool.
## Features
- Simple and slim (only 1.3k gz).
- Not extending built-in objects.
- Legacy IE support (IE6+).
- simple and slim. only 1.2k gz
- not extending built-in objects
- legacy IE support. IE6+
## Installation
Node.js:
```Shell
```shell
$ npm install date-and-time --save
```
Bower:
```shell
$ bower install date-and-time
```
browser:

@@ -19,14 +25,17 @@ ```html

```
## Usage
Node.js:
```JavaScript
```javascript
var date = require('date-and-time');
```
browser:
```JavaScript
```javascript
var date = window.date;
```
## Functions
## API
### format(date, formatString)
```JavaScript
```javascript
var now = new Date();

@@ -58,4 +67,5 @@ date.format(now, 'YYYY/MM/DD HH:mm:ss'); // => '2015/01/02 23:14:05'

| S | millisecond | 7, 0 |
### parse(dateString, formatString)
```JavaScript
```javascript
date.parse('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss'); // => Date object

@@ -81,39 +91,47 @@ date.parse('02-01-2015', 'DD-MM-YYYY'); // => Date object

| S | millisecond | 7, 0 |
### addYears(date, years)
```JavaScript
```javascript
var now = new Date();
var next_year = date.addYears(now, 1); // => Date object
```
### addMonths(date, months)
```JavaScript
```javascript
var now = new Date();
var next_month = date.addMonths(now, 1); // => Date object
```
### addDays(date, days)
```JavaScript
```javascript
var now = new Date();
var yesterday = date.addDays(now, -1); // => Date object
```
### addHours(date, hours)
```JavaScript
```javascript
var now = new Date();
var an_hour_ago = date.addHours(now, -1); // => Date object
```
### addMinutes(date, minutes)
```JavaScript
```javascript
var now = new Date();
var two_minutes_later = date.addMinutes(now, 2); // => Date object
```
### addSeconds(date, seconds)
```JavaScript
```javascript
var now = new Date();
var three_seconds_ago = date.addSeconds(now, -3); // => Date object
```
### addMilliseconds(date, milliseconds)
```JavaScript
```javascript
var now = new Date();
var a_millisecond_later = date.addMilliseconds(now, 1); // => Date object
```
### subtract(date1, date2)
```JavaScript
```javascript
var today = new Date(2015, 0, 2);

@@ -127,4 +145,5 @@ var yesterday = new Date(2015, 0, 1);

```
### isValid(dateString, formatString)
```JavaScript
```javascript
date.isValid('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss'); // => true

@@ -134,4 +153,5 @@ date.isValid('02-29-2015', 'DD-MM-YYYY'); // => false

`formatString` is the same as one of `parse`.
### isLeapYear(date)
```JavaScript
```javascript
var date1 = new Date(2015, 0, 2);

@@ -142,5 +162,6 @@ var date2 = new Date(2012, 0, 2);

```
## Locale
Months, day of week, and meridian are written in English. If you want to change language, rewrite them.
```JavaScript
```javascript
var date = require('date-and-time');

@@ -160,2 +181,3 @@

```
## For developers in Japan (about [12-hour clock](http://en.wikipedia.org/wiki/12-hour_clock))

@@ -167,3 +189,3 @@ 日本では時刻を午前と午後に分ける12時間制の表現が英米式と異なるばかりでなく、それ自体に曖昧さがあり、しばしば混乱が生じます。

```JavaScript
```javascript
var date = require('date-and-time');

@@ -184,5 +206,7 @@

上記の例はWikipediaで説明されている「日本時計協会」方式です。「日本式」はロジックがより複雑になるため割愛させていただきます。
## Browser Support
Chrome, Firefox, Safari, Opera, and Internet Explorer 6+.
## License
MIT

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc