Skip to content

Commit

Permalink
24h am pm (#17)
Browse files Browse the repository at this point in the history
* am/pm handling improvement
* closes #16
  • Loading branch information
codemonkey-uk authored Dec 15, 2021
1 parent 8103f96 commit 220e4c6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ This add on put you in control. You decide how times from around the world appea

2:30 pm UTC

12:00 am GMT is midnight.

1200 pm GMT is noon
1300 pm GMT is invalid, but treat it as 1pm

## Status Icons
Most users prefer the Selected Text mode. For sites where text selection isnt possible, you can temporarly toggle Insert Everywhere on and off for the current tab using the browser action button. For at a glance reading the add on mode, the icons changes depending on its current mode of operation.

Expand Down
19 changes: 17 additions & 2 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,24 @@ function processText (text, fn)
var minute = found[2] ? parseInt(found[2]) : 0;
var second = found[3] ? parseInt(found[3]) : 0;

// check for AM/PM, add 12 to hours if PM is found
var ampm = found[4];
if (ampm && ampm.toUpperCase().charAt()==="P")
hour += 12;
if (ampm)
{
if (ampm.toUpperCase().charAt()==="P")
{
// if hours 13+ the "PM" can be ignored,
// the time is already 24h clock
if (hour<12)
hour += 12;
}
else if (ampm.toUpperCase().charAt()==="A")
{
// 12 am is 00:00 (midnight) in 24h clock
if (hour==12)
hour -= 12;
}
}

var zone = found[5];
if (utc_offsets[zone])
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = local_time
VERSION = 0_5
VERSION = 0_5_1
BUILD_DIR = release
BUILD_FILE = $(BUILD_DIR)/$(NAME)_$(VERSION).zip
FILES = browser-polyfill.js core.js content.js background.js manifest.json LICENSE icon-512.png icon-128.png options.js options.html popup.css button*.png
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Localise Timezones",
"description": "Converts times to your local time zone",
"version": "0.5",
"version": "0.5.1",
"icons": {
"128": "icon-128.png",
"512": "icon-512.png"
Expand Down

0 comments on commit 220e4c6

Please sign in to comment.