Render and accept the minus sign, tweak weights
parent
949bbc0bb8
commit
4776226b6e
|
@ -5,7 +5,7 @@
|
||||||
html {
|
html {
|
||||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||||
font-feature-settings: "case", "tnum", "ss03", "cv09", "cv08", "cv10", "cv11";
|
font-feature-settings: "case", "tnum", "ss03", "cv09", "cv08", "cv10", "cv11";
|
||||||
line-height: 1.5;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
@supports (font-variation-settings: normal) {
|
@supports (font-variation-settings: normal) {
|
||||||
html {
|
html {
|
||||||
|
@ -204,22 +204,25 @@ d-zoneinfo {
|
||||||
|
|
||||||
d-zonename {
|
d-zonename {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
|
||||||
font-size: 0.75em;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d-zoneoffset {
|
d-zoneoffset {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
font-size: 0.75em;
|
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
@media (max-width: 675px) {
|
||||||
|
d-zoneoffset {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d-date {
|
d-date {
|
||||||
margin-top: 0.25em;
|
|
||||||
display: block;
|
display: block;
|
||||||
|
margin-top: 0.25em;
|
||||||
|
|
||||||
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Right container */
|
/* Right container */
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrZoneOffsetInvalid is thrown when a zone string is an invalid zone offset
|
// ErrZoneOffsetInvalid is thrown when a zone string is an invalid zone offset
|
||||||
|
@ -13,7 +14,7 @@ var ErrZoneOffsetInvalid = errors.New("offset zone invalid")
|
||||||
const zoneHour = 60 * 60
|
const zoneHour = 60 * 60
|
||||||
const zoneMinute = 60
|
const zoneMinute = 60
|
||||||
|
|
||||||
var zoneOffsetRegexp = regexp.MustCompile(`^[+-][0-9]{2}:[0-9]{2}$`)
|
var zoneOffsetRegexp = regexp.MustCompile("^[+-\u2212][0-9]{2}:[0-9]{2}$")
|
||||||
|
|
||||||
// ParseZoneOffset parses a zone string into an offset
|
// ParseZoneOffset parses a zone string into an offset
|
||||||
func ParseZoneOffset(zone string) (int, error) {
|
func ParseZoneOffset(zone string) (int, error) {
|
||||||
|
@ -23,15 +24,17 @@ func ParseZoneOffset(zone string) (int, error) {
|
||||||
// Assume that if it satisfies the regex, it satisfies the length and won't
|
// Assume that if it satisfies the regex, it satisfies the length and won't
|
||||||
// fail to parse
|
// fail to parse
|
||||||
d := 0
|
d := 0
|
||||||
if zone[0] == '+' {
|
if strings.HasPrefix(zone, "+") {
|
||||||
d = 1
|
d = 1
|
||||||
}
|
}
|
||||||
if zone[0] == '-' {
|
if strings.HasPrefix(zone, "-") || strings.HasPrefix(zone, "\u2212") {
|
||||||
d = -1
|
d = -1
|
||||||
}
|
}
|
||||||
h, _ := strconv.ParseUint(zone[1:1+2], 10, 64)
|
zone = strings.TrimLeft(zone, "+-\u2212")
|
||||||
|
parts := strings.Split(zone, ":")
|
||||||
|
h, _ := strconv.ParseUint(parts[0], 10, 64)
|
||||||
// Allow hour offsets greater that 24
|
// Allow hour offsets greater that 24
|
||||||
m, _ := strconv.ParseUint(zone[1+3:1+3+2], 10, 64)
|
m, _ := strconv.ParseUint(parts[1], 10, 64)
|
||||||
if m >= 60 {
|
if m >= 60 {
|
||||||
return 0, ErrZoneOffsetInvalid
|
return 0, ErrZoneOffsetInvalid
|
||||||
}
|
}
|
||||||
|
@ -44,11 +47,11 @@ func FormatZoneOffset(offset int) string {
|
||||||
neg := offset < 0
|
neg := offset < 0
|
||||||
s := '+'
|
s := '+'
|
||||||
if neg {
|
if neg {
|
||||||
s = '-'
|
s = '\u2212'
|
||||||
offset = -offset
|
offset = -offset
|
||||||
}
|
}
|
||||||
if offset == 0 {
|
if offset == 0 {
|
||||||
return "\u00B100:00"
|
return "\u00b100:00"
|
||||||
}
|
}
|
||||||
h := offset / zoneHour
|
h := offset / zoneHour
|
||||||
m := (offset % zoneHour) / zoneMinute
|
m := (offset % zoneHour) / zoneMinute
|
||||||
|
|
|
@ -26,6 +26,16 @@ func TestParseZoneOffset(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset, err = ParseZoneOffset("\u221251:59")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("want error %v, got error %v", nil, err)
|
||||||
|
} else {
|
||||||
|
want := -(51*60*60 + 59*60)
|
||||||
|
if offset != want {
|
||||||
|
t.Errorf("got %d, want %d", offset, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err = ParseZoneOffset("-0030")
|
_, err = ParseZoneOffset("-0030")
|
||||||
if err != ErrZoneOffsetInvalid {
|
if err != ErrZoneOffsetInvalid {
|
||||||
t.Errorf("want error %v, got error %v", ErrZoneOffsetInvalid, err)
|
t.Errorf("want error %v, got error %v", ErrZoneOffsetInvalid, err)
|
||||||
|
@ -77,7 +87,7 @@ func TestFormatZoneOffset(t *testing.T) {
|
||||||
t.Fatalf("got offset %v, want offset %v", got, want)
|
t.Fatalf("got offset %v, want offset %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
want, got = "-12:15", FormatZoneOffset(-(12*60*60 + 15*60))
|
want, got = "\u221212:15", FormatZoneOffset(-(12*60*60 + 15*60))
|
||||||
if want != got {
|
if want != got {
|
||||||
t.Fatalf("got offset %v, want offset %v", got, want)
|
t.Fatalf("got offset %v, want offset %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue