{"id":17226355,"url":"https://github.com/ccforward/date-calc","last_synced_at":"2025-04-14T01:10:59.023Z","repository":{"id":150262519,"uuid":"71626905","full_name":"ccforward/date-calc","owner":"ccforward","description":"A simple date calculator","archived":false,"fork":false,"pushed_at":"2020-10-01T17:12:19.000Z","size":8,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T20:20:30.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccforward.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-22T08:32:58.000Z","updated_at":"2018-01-09T09:44:32.000Z","dependencies_parsed_at":"2023-04-12T17:16:46.192Z","dependency_job_id":null,"html_url":"https://github.com/ccforward/date-calc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fdate-calc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fdate-calc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fdate-calc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fdate-calc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccforward","download_url":"https://codeload.github.com/ccforward/date-calc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804825,"owners_count":21164135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T04:15:59.916Z","updated_at":"2025-04-14T01:10:59.004Z","avatar_url":"https://github.com/ccforward.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]\n\n# Simple Date Calculator: DateCalc\n\nA simple date calculator from my personal project [Zhihu-Spider](https://github.com/ccforward/zhihu)\n\n\n## NPM\n\n[DateCalc](https://www.npmjs.com/package/date-calc)\n\n## Test\nTest Framework is `ava` \n\n``` shell\nnpm install\nnpm test\n```\n\n## update\n\n#### @v1.0.6\nadd the `time(timestamp)` function that returns full date\n\n\n#### @v1.0.6\nadd the `beforeCN` and `afterCN` function that returns chinese format days\n\n#### @v1.0.5\nfix bug of `monthEN()` function\n\n#### @v1.0.4\nadd the `today` function \n\n```js\nconst DateCalc = require('date-calc')\nconst d = new DateCalc()\n\nd.today() // returns today date\n\n```\n\n#### @v1.0.3\n\nfix the `new Date()` bug of Safari of macOS and iOS\n\n#### @v1.0.2\n\n1. update: method `now()`\n\n  The `now()` can receive a parameter like `now(20161001)`\n\n  ``` js\n  const DateCalc = require('date-calc')\n  let d = new DateCalc();\n  console.log(d.now()) // returns now date\n  d.now('20161002')  // changs DateCalc's inner data\n  console.log(d.now()) // returns 20161002\n  console.log(d.before()) // returns 20161001\n  console.log(d.after(10)) // returns 20161012\n  ```\n\n2. add: method `weekDay()`\n  \n  The `weekDay()` returns an Object of weekdays info\n\n  ``` js\n  const DateCalc = require('date-calc')\n  let d = new DateCalc('20161001');\n  d.weekDay() // returns { day: 6, en: 'Sat', cn: '六' }\n  ```\n\n## Usage\n\n``` js\nconst DateCalc = require('date-calc')\n// or ES2015\n// import DateCalc from 'date-calc'\n\nlet d = new DateCalc('20460818');\nd.before();\nd.after();\nd.before(2);\nd.after(2);\nd.now();\nd.month();\nd.beforeMonth()\nd.afterMonth()\n\n```\n\n## Parameters\n\n* `new DateCalc()` no parameters means today\n* `new DateCalc('20460818')`  reference date\n\n## Instance Method\n\n* `d.before()` the day before reference date 20460817\n* `d.after()` the day after reference date 20460819\n* `d.before(2)` twos days before reference date 忽略初始天数 20460816\n* `d.after(2)` twos days after reference date 20460820\n* `d.now()` now date 20460818\n* `d.month()` the month of reference date 204608\n* `d.beforeMonth()` the month before reference date 204607\n* `d.afterMonth()` the month after reference date 204609\n* month English descripe\n  * `new DateCalc('20460118').monthEN()` returns 'Jan'\n  * `new DateCalc('20460218').monthEN()` returns 'Feb'\n  * `new DateCalc('20460318').monthEN()` returns 'Mar'\n  * `new DateCalc('20460418').monthEN()` returns 'Apr'\n  * `new DateCalc('20460518').monthEN()` returns 'May'\n  * `new DateCalc('20460618').monthEN()` returns 'Jun'\n  * `new DateCalc('20460718').monthEN()` returns 'Jul'\n  * `new DateCalc('20460818').monthEN()` returns 'Aug'\n  * `new DateCalc('20460918').monthEN()` returns 'Sep'\n  * `new DateCalc('20461018').monthEN()` returns 'Oct'\n  * `new DateCalc('20461118').monthEN()` returns 'Nov'\n  * `new DateCalc('20461218').monthEN()` returns 'Dec'\n* month Chinese descripe  \n  `new DateCalc('20460118').CHN()` returns '2046年01月18日'\n\n[downloads-image]: https://img.shields.io/npm/dm/date-calc.svg\n[npm-url]: https://www.npmjs.com/package/date-calc\n[npm-image]: https://img.shields.io/npm/v/date-calc.svg\n\n[travis-url]: https://travis-ci.org/ccforward/date-calc\n[travis-image]: https://travis-ci.org/ccforward/date-calc.svg?branch=master","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccforward%2Fdate-calc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccforward%2Fdate-calc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccforward%2Fdate-calc/lists"}