{"id":49355102,"url":"https://github.com/bytestrix/timestamplab","last_synced_at":"2026-04-27T13:02:20.060Z","repository":{"id":297216943,"uuid":"996024665","full_name":"bytestrix/TimestampLab","owner":"bytestrix","description":"Lightweight timestamp utilities with automatic seconds/milliseconds detection.","archived":false,"fork":false,"pushed_at":"2026-04-26T11:47:23.000Z","size":414,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-26T12:11:25.971Z","etag":null,"topics":["date","date-formatting","datetime","time","time-formatting","timeconvertion","unixtime","unixtimeconverter","unixtimestamp"],"latest_commit_sha":null,"homepage":"https://timestamplab.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytestrix.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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-04T10:51:53.000Z","updated_at":"2026-04-26T11:47:27.000Z","dependencies_parsed_at":"2025-06-04T18:56:09.828Z","dependency_job_id":"84f8427b-c2c7-43fc-9e48-d3ebf6a1ed43","html_url":"https://github.com/bytestrix/TimestampLab","commit_stats":null,"previous_names":["rishibaghel25/timestamplab","bytestrix/timestamplab"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bytestrix/TimestampLab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytestrix%2FTimestampLab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytestrix%2FTimestampLab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytestrix%2FTimestampLab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytestrix%2FTimestampLab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytestrix","download_url":"https://codeload.github.com/bytestrix/TimestampLab/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytestrix%2FTimestampLab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32337274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["date","date-formatting","datetime","time","time-formatting","timeconvertion","unixtime","unixtimeconverter","unixtimestamp"],"created_at":"2026-04-27T13:02:19.247Z","updated_at":"2026-04-27T13:02:20.046Z","avatar_url":"https://github.com/bytestrix.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TimestampLab\n\nLightweight timestamp utilities with automatic seconds/milliseconds detection. Zero dependencies, ~3KB gzipped.\n\n![TimestampLab demo](./assets/demo.gif)\n\n```bash\nnpm install timestamplab-core\n```\n\n## Why TimestampLab?\n\n**The timestamp-focused library that just works.**\n\n- 🎯 **Auto-detects** seconds vs milliseconds - no need to specify\n- 🪶 **Tiny** - only ~3KB gzipped (smaller than dayjs!)\n- 📦 **Zero dependencies**\n- 🔧 **Full TypeScript support**\n- ⚡ **Fast** - optimized for performance\n- 🌐 **Works everywhere** - Node, Browser, Edge\n\n## The Problem\n\n```javascript\n// With other libraries, YOU must specify:\ndayjs.unix(1777187459)        // Must know it's seconds\ndayjs(1777187459000)          // Must know it's milliseconds\n// ❌ You need to know which one it is!\n```\n\n## The Solution\n\n```javascript\nimport { toMs } from 'timestamplab-core';\n\n// TimestampLab auto-detects:\ntoMs(1777187459);      // ✅ Auto-detects seconds → 1777187459000\ntoMs(1777187459000);   // ✅ Auto-detects milliseconds → 1777187459000\ntoMs('2024-01-01');    // ✅ Auto-detects ISO date → 1704067200000\n```\n\n## Quick Start\n\n```typescript\nimport { toMs, fmtAll, diffTimestamps } from 'timestamplab-core';\n\n// Auto-detect and convert\nconst ms = toMs(1777187459);  // No need to specify unit!\n\n// Format to all formats at once\nconst formatted = fmtAll(1777187459);\nconsole.log(formatted.iso);       // 2026-04-26T07:21:15.000Z\nconsole.log(formatted.relative);  // 2 hours ago\nconsole.log(formatted.local);     // April 26, 2026 at 12:51:15 PM\n\n// Calculate difference\nconst diff = diffTimestamps(1777187459, 1777273859);\nconsole.log(diff.days);  // 1\n```\n\n## Installation\n\n```bash\n# Core utilities\nnpm install timestamplab-core\n\n# CLI tools\nnpm install -g timestamplab-cli\n\n# Interactive world map (React)\nnpm install timestamplab-map\n```\n\n## API\n\n### Detection\n\n```typescript\nimport { detectUnit, detectAndNormalise, isValidTimestamp } from 'timestamplab-core';\n\ndetectUnit(1777187459);      // 's'\ndetectUnit(1777187459000);   // 'ms'\n\ndetectAndNormalise(1777187459);\n// { unit: 's', epochMs: 1777187459000, epochS: 1777187459 }\n\nisValidTimestamp(1777187459);  // true\n```\n\n### Conversion\n\n```typescript\nimport { toMs, toSeconds } from 'timestamplab-core';\n\ntoMs(1777187459);              // 1777187459000 (auto-detected)\ntoMs(1777187459.664);          // 1777187459664 (decimals supported)\ntoMs('2024-01-01');            // 1704067200000 (parsed ISO)\ntoMs(new Date());              // current timestamp\n\ntoSeconds(1777187459000);      // 1777187459\n```\n\n### Formatting\n\n```typescript\nimport { fmtAll, relTime, toISO } from 'timestamplab-core';\n\nfmtAll(1777187459);\n// {\n//   iso: '2026-04-26T07:21:15.000Z',\n//   utc: 'Sun, 26 Apr 2026 07:21:15 GMT',\n//   local: 'April 26, 2026 at 12:51:15 PM',\n//   relative: '2 hours ago',\n//   unix_s: '1777187459',\n//   unix_ms: '1777187459000'\n// }\n\nrelTime(Date.now() - 3600000);  // \"1 hour ago\"\nrelTime(Date.now() + 86400000); // \"in 1 day\"\ntoISO(1777187459);              // \"2026-04-26T07:21:15.000Z\"\n```\n\n### Difference\n\n```typescript\nimport { diffTimestamps, formatDiff } from 'timestamplab-core';\n\nconst diff = diffTimestamps(1777187459, 1777273859);\n// {\n//   days: 1, hours: 0, minutes: 0, seconds: 0,\n//   totalDays: 1, totalHours: 24, totalMinutes: 1440, ...\n// }\n\nformatDiff(diff);  // \"1d 0h 0m 0s\"\n```\n\n### Batch Processing\n\n```typescript\nimport { batchProcess, exportToCSV } from 'timestamplab-core';\n\nconst results = batchProcess(['1777187459', '1777273859', 'invalid']);\n// [\n//   { input: '1777187459', success: true, timestamp: {...}, formatted: {...} },\n//   { input: '1777273859', success: true, timestamp: {...}, formatted: {...} },\n//   { input: 'invalid', success: false, error: 'Invalid timestamp' }\n// ]\n\nconst csv = exportToCSV(results);  // Export to CSV string\n```\n\n## Interactive Map\n\n```bash\nnpm install timestamplab-map\n```\n\n```tsx\nimport { WorldMap } from 'timestamplab-map';\n\nfunction App() {\n  return (\n    \u003cWorldMap\n      onCityClick={(city) =\u003e console.log(city.name, city.tz)}\n      onCountryClick={(country, cities) =\u003e console.log(country.name, cities)}\n      selectedTz=\"Asia/Kolkata\"\n      userCountry=\"India\"\n    /\u003e\n  );\n}\n```\n\nFeatures: 175 countries, 80+ city dots, hover tooltips with live time, click to select, zero dependencies, pure SVG.\n\n## CLI\n\n```bash\nnpm install -g timestamplab-cli\n```\n\n```bash\n# Convert timestamp\ntsl convert 1777187459\n\n# Get current time\ntsl now\n\n# Calculate difference\ntsl diff 1777187459 1777273859\n\n# Batch convert\ntsl batch timestamps.txt --csv output.csv\n\n# Time calculator\ntsl calc 1777187459 +1d      # Add 1 day\ntsl calc 1777187459 -2h30m   # Subtract 2 hours 30 minutes\n```\n\n## TypeScript\n\nFull TypeScript support with complete type definitions:\n\n```typescript\nimport type { \n  TimestampUnit, \n  TimestampInput, \n  TimestampInfo,\n  FormattedTimestamp,\n  TimestampDiff,\n  BatchResult \n} from 'timestamplab-core';\n\ntype TimestampUnit = 's' | 'ms';\ntype TimestampInput = string | number | Date;\n\ninterface FormattedTimestamp {\n  iso: string;\n  utc: string;\n  local: string;\n  relative: string;\n  unix_s: string;\n  unix_ms: string;\n}\n```\n\n## Comparison\n\n| Feature | TimestampLab | date-fns | dayjs | luxon |\n|---------|--------------|----------|-------|-------|\n| Auto-detect | ✅ | ❌ | ❌ | ❌ |\n| Bundle Size | ~3KB | ~13KB | ~7KB | ~72KB |\n| Dependencies | 0 | 0 | 0 | 0 |\n| TypeScript | ✅ Native | ✅ | ✅ | ✅ |\n| Learning Curve | Low | High | Low | Medium |\n| Timestamp Focus | ✅ | ❌ | ❌ | ❌ |\n\n## Use Cases\n\n- **Log Analysis** - Convert timestamps from various sources\n- **API Integration** - Handle different timestamp formats automatically\n- **Analytics Dashboards** - Display time-series data\n- **Chat Applications** - Show relative timestamps (\"2 hours ago\")\n- **Admin Panels** - User activity timestamps\n- **DevOps Tools** - Log monitoring and analysis\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build all packages\nnpm run build\n\n# Run tests\nnpm run test\n```\n\n## Packages\n\n- **timestamplab-core** - Core utilities\n- **timestamplab-cli** - Command-line tools\n- **timestamplab-map** - Interactive world map React component\n\n## License\n\nMIT © TimestampLab\n\n## Links\n\n- [npm - Core](https://www.npmjs.com/package/timestamplab-core)\n- [npm - CLI](https://www.npmjs.com/package/timestamplab-cli)\n- [Web App](https://timestamplab.dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytestrix%2Ftimestamplab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytestrix%2Ftimestamplab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytestrix%2Ftimestamplab/lists"}