{"id":23250559,"url":"https://github.com/chipmunktail/datecounter","last_synced_at":"2026-04-29T12:34:04.047Z","repository":{"id":139046811,"uuid":"139936291","full_name":"chipmunktail/dateCounter","owner":"chipmunktail","description":"A node package , Format date for article or news","archived":false,"fork":false,"pushed_at":"2018-07-22T10:18:40.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T02:14:45.880Z","etag":null,"topics":["es6","jslibrary","npm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chipmunktail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-07-06T05:15:31.000Z","updated_at":"2025-02-23T01:56:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4a33dd9-ea9a-4748-a046-433bcf3c7e25","html_url":"https://github.com/chipmunktail/dateCounter","commit_stats":null,"previous_names":["hjdtl/datecounter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chipmunktail%2FdateCounter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chipmunktail%2FdateCounter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chipmunktail%2FdateCounter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chipmunktail%2FdateCounter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chipmunktail","download_url":"https://codeload.github.com/chipmunktail/dateCounter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423521,"owners_count":20936626,"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":["es6","jslibrary","npm"],"created_at":"2024-12-19T09:12:47.198Z","updated_at":"2026-04-29T12:34:03.968Z","avatar_url":"https://github.com/chipmunktail.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[中文](https://github.com/hjdtl/dateCounter/blob/master/README.zh.md) | [English](https://github.com/hjdtl/dateCounter)\n\n# Datecounter\nA tool class library that changes the time format\n\nFormat date for articles, news or comments\n\n## Usage\n\n### Parameter\nDatecounter receive an **object parameter** , and return a **counter** :\n\n| key | default/type | describe | required |\n| - | :-: | :- | :-: |\n| date | none/Date| Expected is Date Object or timestamp | yes |\n| countDay | 7/number | Countdown days | no |\n| i18n | 'zh'/string | Language | no |\n| raw | none/boolean | Raw data | no |\n\n\n### Essentials\n```javascript\nimport Datecounter from 'Datecounter'\nconst counter=new Datecounter({countDay: 10, i18n: 'en'})\ncounter(new Date())\n```\n\n### Vue\n```javascript\n// for Vue\nimport Vue from 'vue'\nimport {vDatecounter} from 'Datecounter'\nVue.use(vDatecounter, {countDay: 10, i18n: 'en'})\n\n/************************* Global method *************************/\nthis.$datecounter(new Date())\n/************************* Local method *************************/\nconst counter=new this.$Datecounter({countDay: 10, i18n: 'en'})\ncounter(new Date())\n```\n\n### Example\n```javascript\nimport Datecounter from 'Datecounter'\nvar now = new Date() // now : Thu Jul 05 2018 09:20:00\nvar twoMinutesAgo = now - (2 * 60 * 1000)\nvar twoHoursAgo = now - (2 * 60 * 60 * 1000)\nvar fiveDaysAgo = now - (5 * 24 * 60 * 60 * 1000)\nvar eightDaysAgo = now - (8 * 24 * 60 * 60 * 1000)\nvar january = now - (180 * 24 * 60 * 60 * 1000)\nvar aYearsAgo = now - (365 * 24 * 60 * 60 * 1000)\n\n/************************* Default usage *************************/\nconst counter1=new Datecounter({i18n: 'en'})\ncounter1(now)           // return : 0 minutes ago\ncounter1(fiveDaysAgo)   // return : 5 days 0 hours ago\ncounter1(january)       // return : January 6, 9:20\ncounter1(aYearsAgo)     // return : July 5, 2017 9:20\n\n/************************* Countdown days *************************/\nconst counter2=new Datecounter({countDay: 10, i18n: 'en'})\nconst counter3=new Datecounter({countDay: 7, i18n: 'en'})\ncounter2(eightDaysAgo)  // return : 8 days 0 hours ago\ncounter3(eightDaysAgo)  // return : June 27, 9:20\n\n/************************* i18n *************************/\n/* langList = ['zh', 'en', 'jp', 'ru', 'kr', 'fr', 'vi'] */\n/* Now noly have ['zh', 'en', 'jp'] , other language are being developed */\nconst counter_zh=new Datecounter({i18n: 'zh'})\nconst counter_en=new Datecounter({i18n: 'en'})\nconst counter_jp=new Datecounter({i18n: 'jp'})\ncounter_zh(fiveDaysAgo) // return : 5天0小时前\ncounter_en(fiveDaysAgo) // return : 5 days 0 hours ago\ncounter_jp(fiveDaysAgo) // return : 5天0時間前\n```\n\n### Get raw data\n```javascript\n/* If you need raw data */\n/* There are four kinds of data types in all ['history', 'countDown_day', 'countDown_hour', 'countDown_minute'] */\nconst count_raw=new Datecounter({raw: true})\ncount_raw(twoMinutesAgo)// return : {type: \"countDown_minute\", minute: 2}\ncount_raw(twoHoursAgo)  // return : {type: \"countDown_hour\", hour: \"2\", minute: \"0\"}\ncount_raw(fiveDaysAgo)  // return : {type: \"countDown_day\", day: \"5\", hour: \"0\"}\ncount_raw(january)      // return : {type: \"history\", year: null, month: 1, date: 6, hour: 9, minute: 20 }\ncount_raw(aYearsAgo)    // return : {type: \"history\", year: 2017, month: 7, date: 6, hour: 9, minute: 20 }\n```\n\n\n---\nIf you are good at these languages ['en', 'jp', 'ru', 'kr', 'fr', 'vi'], maybe you can help me.😄","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchipmunktail%2Fdatecounter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchipmunktail%2Fdatecounter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchipmunktail%2Fdatecounter/lists"}