{"id":22382530,"url":"https://github.com/jcoreio/date-goggles","last_synced_at":"2025-07-19T19:34:26.060Z","repository":{"id":39172876,"uuid":"252563473","full_name":"jcoreio/date-goggles","owner":"jcoreio","description":"see numeric timestamps in text as dates","archived":false,"fork":false,"pushed_at":"2023-01-05T10:46:20.000Z","size":1634,"stargazers_count":0,"open_issues_count":30,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-09T16:08:45.940Z","etag":null,"topics":["date","timestamp"],"latest_commit_sha":null,"homepage":"https://jcoreio.github.io/date-goggles/","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/jcoreio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-02T21:03:50.000Z","updated_at":"2020-04-02T21:19:15.000Z","dependencies_parsed_at":"2023-02-04T01:46:03.753Z","dependency_job_id":null,"html_url":"https://github.com/jcoreio/date-goggles","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jcoreio/date-goggles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fdate-goggles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fdate-goggles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fdate-goggles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fdate-goggles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcoreio","download_url":"https://codeload.github.com/jcoreio/date-goggles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fdate-goggles/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265999009,"owners_count":23862219,"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":["date","timestamp"],"created_at":"2024-12-05T00:13:22.215Z","updated_at":"2025-07-19T19:34:26.039Z","avatar_url":"https://github.com/jcoreio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# date-goggles\n\n[![CircleCI](https://circleci.com/gh/jcoreio/date-goggles.svg?style=svg)](https://circleci.com/gh/jcoreio/date-goggles)\n[![Coverage Status](https://codecov.io/gh/jcoreio/date-goggles/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/date-goggles)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![npm version](https://badge.fury.io/js/date-goggles.svg)](https://badge.fury.io/js/date-goggles)\n\nOur work involves lots of numeric timestamps in JSON. This leads to a lot of log output like:\n\n```\n[2020-04-01 18:32:22 TrackedEntityActivityRecordAPI] INFO calling historian.putData:  { '_org/5/Employees/148':\n{ t: [ 1585777672134, 1585778400000 ],\n  v: [ 'Stuffing', null ],\n  beginTime: 1585777672134,\n```\n\nWhich can be tedious to debug because numeric timestamps are inscrutable. `date-goggles` helps by searching for numbers that\nseem to be timestamps and converting them to `Dates`:\n\n```\n[2020-04-01 18:32:22 TrackedEntityActivityRecordAPI] INFO calling historian.putData:  { '_org/5/Employees/148':\n{ t: [ 4/1/2020, 4:47:52 PM, 4/1/2020, 5:00:00 PM ],\n  v: [ 'Stuffing', null ],\n  beginTime: 4/1/2020, 4:47:52 PM,\n```\n\n# Table of Contents\n\n\u003c!-- toc --\u003e\n\n- [Node.js API](#nodejs-api)\n  - [`dateGoggles(input, options)`](#dategogglesinput-options)\n  - [`parse(input, options)`](#parseinput-options)\n  - [`format(ast, options)`](#formatast-options)\n- [CLI](#cli)\n\n\u003c!-- tocstop --\u003e\n\n# Node.js API\n\n## `dateGoggles(input, options)`\n\nTransforms the output with `format(parse(input, options), options)`.\nSee [`parse`](#parseinput-options) and [`format`](#formatast-options) for `options` documentation.\n\n## `parse(input, options)`\n\nParses input text.\n\n### Arguments\n\n#### `input: string` (**required**)\n\nThe input to parse.\n\n#### `options.unit` (`'milliseconds' | 'seconds'`, _optional_)\n\nThe timestamp unit. If omitted, tries to guess based upon the input or numeric `options.min`/`options.max`.\n\n#### `options.min` (`number | Date | null | undefined`, _optional_)\n\nNumbers found in the input less than this will not be considered timestamps.\nIf you pass `null`, no lower bound is used. If `undefined` or omitted, defaults to 10 years ago.\n\n#### `options.max` (`number | Date | null | undefined`, _optional_)\n\nNumbers found in the input greater than this will not be considered timestamps.\nIf you pass `null`, there's no upper bound. If `undefined` or omitted, defaults to 5 years into the future.\n\n### Returns: `Array\u003cstring | Date\u003e`\n\nThe input split up in to substrings in which no timestamps were found, and timestamps\nconverted to `Date`s.\n\n## `format(ast, options)`\n\nFormats a parsed AST.\n\n### Arguments\n\n#### `ast: Array\u003cstring | Date\u003e` (**required**)\n\nThe AST output of `parse`.\n\n#### `options.formatDate` (`(date: Date) =\u003e string`, _optional_)\n\nCustomizes how `Date`s are formatted.\n\n### Returns: `string`\n\nThe formatted output.\n\n# CLI\n\nThe CLI is pretty basic and doesn't have any options to customize output right now,\nit just parses file arguments or stdin and outputs using `date.toLocaleString()`:\n\n```\ndate-goggles app1.log app2.log\n```\n\nOR\n\n```\nsome-command | date-goggles\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Fdate-goggles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcoreio%2Fdate-goggles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Fdate-goggles/lists"}