Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/straticjs/stratic-handle-offset
Return a properly configured MomentJS moment for a Stratic post
https://github.com/straticjs/stratic-handle-offset
hacktoberfest javascript plumbing stratic
Last synced: about 1 month ago
JSON representation
Return a properly configured MomentJS moment for a Stratic post
- Host: GitHub
- URL: https://github.com/straticjs/stratic-handle-offset
- Owner: straticjs
- License: lgpl-3.0
- Created: 2017-09-24T23:55:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-01T01:02:31.000Z (over 4 years ago)
- Last Synced: 2025-01-07T13:55:24.544Z (about 1 month ago)
- Topics: hacktoberfest, javascript, plumbing, stratic
- Language: JavaScript
- Homepage:
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# `stratic-handle-offset`
[![Build Status](https://travis-ci.org/straticjs/stratic-handle-offset.svg?branch=master)](https://travis-ci.org/straticjs/stratic-handle-offset)
[![Coverage Status](https://coveralls.io/repos/github/straticjs/stratic-handle-offset/badge.svg?branch=master)](https://coveralls.io/github/straticjs/stratic-handle-offset?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/straticjs/stratic-handle-offset.svg)](https://greenkeeper.io/)Return a properly configured [MomentJS][1] moment for a Stratic post
## Installation
npm install stratic-handle-offset
## Usage
All this does is make sure that UTC offset information in Stratic posts is handled properly. This is pretty simple but is easy to forget to do (or to forget the details of how to do) - hence this module.
The module exports a single function. In order to use it, just pass the function the Stratic post's time information object (almost always `file.data.time`). You will get back a [MomentJS][1] moment with the offset information all set up so that when you call `moment#month()`, `moment#year()`, etc., everything Just Works™ and you get back accurate information.
## Example
```js
var handleOffset = require('stratic-handle-offset');
var through2 = require('through2');through2.obj(function(file, enc, callback) {
var date = handleOffset(file.data.time);
// `date` is now a MomentJS moment; do with that what you will
// E.g.:var year = date.year();
}
```## Code of Conduct
Please note that StraticJS is developed under the [Contributor Covenant][2] Code of Conduct. Project contributors are expected to respect these terms.
For the full Code of Conduct, see [CODE_OF_CONDUCT.md][3]. Violations may be reported to .
## License
LGPL 3.0+
## Author
AJ Jordan
[1]: http://momentjs.com/
[2]: http://contributor-covenant.org/
[3]: https://github.com/straticjs/stratic-handle-offset/blob/master/CODE_OF_CONDUCT.md