{"id":23196290,"url":"https://github.com/letstri/timezz","last_synced_at":"2025-12-12T04:02:08.428Z","repository":{"id":25627565,"uuid":"104678116","full_name":"letstri/timezz","owner":"letstri","description":"With this plugin, you can easily make a stopwatch or timer on your site. Just init, style and enjoy.","archived":false,"fork":false,"pushed_at":"2025-03-25T21:18:30.000Z","size":2104,"stargazers_count":45,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T01:28:48.055Z","etag":null,"topics":["commonjs","es6","javascript","js","library","plugin","repeat","stopwatch","time","timer","timezz","typescript","ui","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/letstri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2017-09-24T21:38:56.000Z","updated_at":"2025-03-25T21:18:32.000Z","dependencies_parsed_at":"2024-02-02T00:04:33.733Z","dependency_job_id":null,"html_url":"https://github.com/letstri/timezz","commit_stats":null,"previous_names":["striletscode/timezz","brooons/timezz"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftimezz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftimezz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftimezz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftimezz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letstri","download_url":"https://codeload.github.com/letstri/timezz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485287,"owners_count":20946398,"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":["commonjs","es6","javascript","js","library","plugin","repeat","stopwatch","time","timer","timezz","typescript","ui","webpack"],"created_at":"2024-12-18T14:17:38.102Z","updated_at":"2025-12-12T04:02:03.083Z","avatar_url":"https://github.com/letstri.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TimezZ\n\n\u003e With this plugin, you can easily make a stopwatch or timer on your site. Just init, style and enjoy.\n\n[![npm version](https://badge.fury.io/js/timezz.svg)](https://www.npmjs.com/package/timezz)\n[![](https://data.jsdelivr.com/v1/package/npm/timezz/badge)](https://www.jsdelivr.com/package/npm/timezz)\n\n## Features\n\n- Typescript support\n- Support all environments\n- Easy customization\n- Simple and lightweight\n\n## Demo\n\n[Demo](https://codesandbox.io/s/nervous-flower-v1fkb)\n\n## Quick start\n\n### Install\n\n```shell\nnpm i timezz\n```\n\n#### CDN\n\nFor native ES Modules, there is also an ES Modules compatible build:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import timezz from 'https://cdn.jsdelivr.net/npm/timezz@9.0.2/+esm';\n\u003c/script\u003e\n```\n\n### HTML\n\nHere is a base HTML markup for your timer/stopwatch. Main part of HTML are `data` attributes for render numbers of `years`, `days`, `hours`, `minutes`, `seconds`. Every `data` attribute isn't mandatory, TimezZ will recalculate time to smaller numbers.\n\nFor example:\n - if you don't have years, a timer will add these years to days\n - if you don't have days, a timer will add these days to hours\n - and so on\n\n```html\n\u003cdiv class=\"timer\"\u003e\n  Years: \u003cdiv data-years\u003e\u003c/div\u003e\n  Days: \u003cdiv data-days\u003e\u003c/div\u003e\n  Hours: \u003cdiv data-hours\u003e\u003c/div\u003e\n  Minutes: \u003cdiv data-minutes\u003e\u003c/div\u003e\n  Seconds: \u003cdiv data-seconds\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n### Initialization\n\n#### ES6\n\nTimezZ as an ES6 module.\n\n```js\nimport timezz from 'timezz'\n\ntimezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n```\n\n---\n\n## Parameters\n\nFull config with filled params:\n\n```ts\ntimezz(document.querySelector('.timer'), {\n  date: new Date(),\n  pause: false,\n  stopOnZero: true,\n  beforeCreate() {},\n  beforeUpdate() {},\n  update(event) {},\n})\n```\n\n### element\n\n- type: `HTMLElement`\n- required `true`\n\n```ts\ntimezz(document.querySelector('.timer'), { date: new Date() })\n```\n\n### date\n\nDate from and to which you want to count. Preferred `Date`.\n\n- type: `Date | string | number`\n- required `true`\n\n```ts\n// Date instance\nnew Date('1996-05-27 03:15')\n\n// String\n'1996-05-27 03:15'\n\n// Timestamp\n833156100000\n```\n\n### pause\n\nIs the timer can updating every second?\n\n- type: `boolean`\n- default: `false`\n- required `false`\n\nCan update after initialization.\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.pause = true\n```\n\n### stopOnZero\n\nShould the timer continue after end of date point? Only for date in future.\n\n- type: `boolean`\n- default: `true`\n- required `false`\n\nCan update after initialization.\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.stopOnZero = false\n```\n\n### beforeCreate\n\nThe function will be called before instance initialization\n\n- type: `function`\n- default: `undefined`\n- required `false`\n\nCan set after initialization.\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.beforeCreate = () =\u003e {}\n```\n\n### beforeUpdate\n\nThe function will be called on before each second with an event.\n\n- type: `function`\n- default: `undefined`\n- required `false`\n\nCan set after initialization.\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.beforeUpdate = () =\u003e {}\n```\n\n### update\n\nThe function will be called on each second with an event.\n\n- type: `function`\n- default: `undefined`\n- required `false`\n\nCan set after initialization.\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.update = (event) =\u003e {}\n```\n\n## API\n\n### destroy\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.destroy()\n```\n\n### init\n\nAfter destroy you can init instance again.\n\n```ts\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date(),\n})\n\ntimer.destroy()\n\nsetTimeout(() =\u003e {\n  timer.init()\n}, 1000)\n```\n\n## Interfaces\n\n### Timezz\n\nThe interface can be declared as a type of instance.\n\n```ts\nimport timezz, { Timezz } from 'timezz'\n\nconst plugins: {\n  timezz: Timezz\n} = {\n  timezz: null,\n}\n\nplugins.timezz = timezz(document.querySelector('.timer'), { date: new Date('1996-05-27 03:15') })\n```\n\n### UpdateEvent\n\nThe interface will be sent on each call of the `update` method.\n\n```ts\nimport { UpdateEvent } from 'timezz'\n\nconst data: {\n  info: UpdateEvent | null\n} = {\n  info: null,\n}\n\nconst timer = timezz(document.querySelector('.timer'), {\n  date: new Date('1996-05-27 03:15'),\n\n  update(event) {\n    data.info = event\n  },\n})\n```\n\n## React\n\n```tsx\nimport type { UpdateEvent } from 'timezz'\nimport { Timezz } from 'timezz/react'\n\nexport default function App() {\n  function onUpdate(event: UpdateEvent) {\n    console.log(event)\n  }\n\n  return (\n    \u003cTimezz\n      date={new Date('2026-01-01')}\n      pause={false}\n      stopOnZero={true}\n      onUpdate={onUpdate}\n    \u003e\n      \u003cdiv\u003e\n        Years:\n        \u003cdiv data-years\u003e\u003c/div\u003e\n      \u003c/div\u003e\n      \u003cdiv\u003e\n        Days:\n        \u003cdiv data-days\u003e\u003c/div\u003e\n      \u003c/div\u003e\n      \u003cdiv\u003e\n        Hours:\n        \u003cdiv data-hours\u003e\u003c/div\u003e\n      \u003c/div\u003e\n      \u003cdiv\u003e\n        Minutes:\n        \u003cdiv data-minutes\u003e\u003c/div\u003e\n      \u003c/div\u003e\n      \u003cdiv\u003e\n        Seconds:\n        \u003cdiv data-seconds\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/Timezz\u003e\n  )\n}\n```\n\n## Vue\n\n```vue\n\u003cscript setup lang=\"ts\"\u003e\nimport type { UpdateEvent } from 'timezz'\nimport { Timezz } from 'timezz/vue'\n\nfunction onUpdate(event: UpdateEvent) {\n  console.log(event)\n}\n\u003c/script\u003e\n\n\u003ctemplate\u003e\n  \u003cTimezz\n    :date=\"new Date('2026-01-01')\"\n    :pause=\"false\"\n    :stop-on-zero=\"true\"\n    @update=\"onUpdate\"\n  \u003e\n    \u003cdiv\u003e\n      Years:\n      \u003cdiv data-years /\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      Days:\n      \u003cdiv data-days /\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      Hours:\n      \u003cdiv data-hours /\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      Minutes:\n      \u003cdiv data-minutes /\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      Seconds:\n      \u003cdiv data-seconds /\u003e\n    \u003c/div\u003e\n  \u003c/Timezz\u003e\n\u003c/template\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletstri%2Ftimezz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletstri%2Ftimezz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletstri%2Ftimezz/lists"}