Started: Sep 2019
A Chrome extension that converts a date time to a new time zone of the user's choice.
- It automatically converts any times of:
YYYY-MM-DD HH:MM:SS
format to the user's chosen default. It also has a manual converter if the page hasn't automatically converted (can also convert Unix time).
Assumptions
- There is one default timezone that the times on a page are generated in (defaults to "America/Los_Angeles"
- They are all contained in the same HTML entity (such as
td
)
- See Extending for details on how to modify defaults and extend to support other formats
Run npm install
- Run
npm run dev
- Open
mock_site/index-dev.html
-
Run
npm run build
-
Production usage is through a Chrome extension. It will run / show on any page that you have configured against
matches
undercontent_scripts
in thedist/manifest.json
file. The currentmanifest
defaults to allhttps://
websites. -
For local testing, the
dist
folder can be added into your extensions in Chrome chrome://extensions/. You will need to turn ondeveloper mode
before you can add an extension this way, see Developer Mode -
After
developer mode
has been turned on, simply drag thedist
folder or load unpacked here: chrome://extensions/
Note: the page initial default is set to "America/Los_Angeles" which can be changed via PAGE_DEFAULT_TIMEZONE
in src/main.js
.
- Open
mock-site/index-dev.html
in a Chrome browser - Click the clock icon that should appear up the top right
- Change the page Time Zone and click Convert
- Manually enter a Date Time or Unix Time with from - to Time Zones via text input or through the picker, and click Convert
There should also be the clock icon in your Chrome extensions tray (you may need to pin it), this can be used to manually convert whereever you are in Chrome regardless of the manifest.json
In order to add additional formats to convert, the following files need to be updated under src/conversion
:
/config/index.ts
here you can change the default time zone of the page/config/regex.ts
here you will add any formats as regular expressions that will be converted. Exporting them via theregexsToReplace
array./toUnixTime.ts
here you will create your function to convert the date time format returning a unix time. Then adding to thetoUnixFuncs
array.
Note: /momentInterface.ts
is a simple interface to the moment library which can be used and updated for step 3