Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploratory PR for backwards-compatible changes & cross-env alignment: timeFormat #915

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

webketje
Copy link

@webketje webketje commented Nov 3, 2022

I started this effort because I was in sore need of localized dates (we have Java & Node microservices and it's a pain that one takes into account timezone while the other does not). Then I realized there was a lot more I could do that would be both backwards-compatible, more powerful and more aligned across browser and Node. So this PR:

  • Adds timeFormat option to debug instances, settable as DEBUG_TIME_FORMAT env var
  • Deprecates hideDate option, equated to timeFormat === 'none'
  • Allows timeFormat of choice: none, iso, diff, or localized (taking into account process.env.TZ in Node, and timezoneOffset in browser)
  • Normalizes behavior across browser & Node: all timeFormats are available in both, but the defaults are kept as-is.
  • Deprecates createDebug.humanize as public member and adds createDebug.withTimeFormat helper instead
  • Documents this in the README.
  • Adds debug format tests that are compatible with browser & Node.

@Qix- I was surprised at how outdated (dev)Dependencies are and was unable to run npm test (only mocha test.js directly), and dind't find any CI script. The browserify build was not documented so I added an NPM script for it.. It may be useful to add it to the NPM files for those of us wanting to use debug in the browser by copying the dist to an asset folder. I think this change is fully backwards-compatible (at least all tests succeed including the 5 new ones I added)

…oss browser and Node

* Adds timeFormat option to debug instances, settable as DEBUG_TIME_FORMAT env var
* Deprecates hideDate option, equated to timeFormat === 'none'
* Allows timeFormat of choice: none, iso, diff, or localized (taking into account process.env.TZ)
* Normalizes behavior across browser & Node: all timeFormats are available in both, but the defaults are kept as-is.
* Deprecates createDebug.humanize and adds createDebug.withTimeFormat helper instead
… be tested against both browser & NodeJS envs
@webketje
Copy link
Author

webketje commented Feb 16, 2023

@Qix- feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants