Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Mao committed May 20, 2015
0 parents commit 24d32c2
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
npm-debug.log
5 changes: 5 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"preset": "google",
"maximumLineLength": null,
"excludeFiles": ["node_modules/**"]
}
15 changes: 15 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"latedef": true,
"mocha" : true,
"newcap": true,
"noarg": true,
"node": true,
"sub": true,
"undef": true,
"unused": true
}
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
after_script: NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
3 changes: 3 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"generator-steves-node": {}
}
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url]

> Get a simple timestamp
Fast as it doesn't have bloated methods.


## Install

```sh
$ npm install --save simple-timestamp
```


## Usage

```js
var simpleTimestamp = require('simple-timestamp');

simpleTimestamp();
// => 2015.05.20.14.34.08
```

```sh
$ npm install --global simple-timestamp
$ simple-timestamp
2015.05.20.14.36.09
```


## License

MIT © [Steve Mao](https://github.com/stevemao)


[npm-image]: https://badge.fury.io/js/simple-timestamp.svg
[npm-url]: https://npmjs.org/package/simple-timestamp
[travis-image]: https://travis-ci.org/stevemao/simple-timestamp.svg?branch=master
[travis-url]: https://travis-ci.org/stevemao/simple-timestamp
[daviddm-image]: https://david-dm.org/stevemao/simple-timestamp.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/stevemao/simple-timestamp
[coveralls-image]: https://coveralls.io/repos/stevemao/simple-timestamp/badge.svg
[coveralls-url]: https://coveralls.io/r/stevemao/simple-timestamp
13 changes: 13 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env node
'use strict';
var meow = require('meow');
var simpleTimestamp = require('./');

meow({
help: [
'Usage',
' simple-timestamp'
].join('\n')
});

console.log(simpleTimestamp());
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var leftPad = require('left-pad');

function pad(num) {
return leftPad(num, 2, 0);
}

module.exports = function() {
var now = new Date();
return now.getFullYear() + '.' + pad(now.getMonth() + 1) + '.' + pad(now.getDate()) + '.' + pad(now.getHours()) + '.' + pad(now.getMinutes()) + '.' + pad(now.getSeconds());
};
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "simple-timestamp",
"version": "0.0.0",
"description": "Get a simple timestamp",
"homepage": "https://github.com/stevemao/simple-timestamp",
"author": {
"name": "Steve Mao",
"email": "maochenyan@gmail.com",
"url": "https://github.com/stevemao"
},
"repository": "stevemao/simple-timestamp",
"license": "MIT",
"files": [
"index.js",
"cli.js"
],
"keywords": [
"simple-timestamp",
"simple",
"time",
"timestamp",
"log"
],
"dependencies": {
"left-pad": "0.0.4",
"meow": "^3.1.0"
},
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.14",
"jscs": "^1.13.1",
"jshint": "^2.7.0",
"mocha": "*"
},
"scripts": {
"coverage": "istanbul cover _mocha -- -R spec && rm -rf ./coverage",
"lint": "jshint *.js test --exclude node_modules && jscs *.js test",
"test": "npm run-script lint && mocha"
},
"bin": "cli.js"
}
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';
var assert = require('assert');
var simpleTimestamp = require('../');

it('should contain current date', function() {
var now = new Date();
var data = simpleTimestamp().split('.');

assert.equal(data[0], now.getFullYear());
assert(data[1].indexOf((now.getMonth() + 1)) >= 0);
assert(data[2].indexOf(now.getDate()) >= 0);
});

0 comments on commit 24d32c2

Please sign in to comment.