Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/date-floor
Like Math.floor but for Date objects
https://github.com/binocarlos/date-floor
Last synced: 10 days ago
JSON representation
Like Math.floor but for Date objects
- Host: GitHub
- URL: https://github.com/binocarlos/date-floor
- Owner: binocarlos
- License: mit
- Created: 2014-04-08T00:52:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-08T11:09:07.000Z (over 10 years ago)
- Last Synced: 2024-09-15T05:26:11.257Z (2 months ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
date-floor
==========![Build status](https://api.travis-ci.org/binocarlos/date-floor.png)
Like Math.floor but for Date objects
## installation
```
$ npm install date-floor
```## usage
Take a date any get back one that is the closest preceding:
* year
* month
* day
* hour
* minute```js
var datefloor = require('date-floor');var d = new Date('05/06/2014 11:56:45');
// 01/01/2014 00:00:00
var year = datefloor(d, 'year');// 05/01/2014 00:00:00
var month = datefloor(d, 'month');// 05/06/2014 00:00:00
var day = datefloor(d, 'day');// 05/06/2014 11:00:00
var hour = datefloor(d, 'hour');// 05/06/2014 11:56:00
var minute = datefloor(d, 'minute');
```## license
MIT