1
0
Fork 0

Remove old code for rewrite

pull/1/head
Ambrose Chua 2020-10-27 20:57:46 +08:00
parent dbe3fb8eef
commit f514f6fc00
7 changed files with 24 additions and 213 deletions

1
CNAME
View File

@ -1 +0,0 @@
datetime.link

5
Caddyfile Normal file
View File

@ -0,0 +1,5 @@
:2015 {
root .
file_server
try_files {path} templates/{path} templates/{path}/index.html
}

View File

@ -12,3 +12,22 @@ Sometimes, you want to refer to a point in time, but want to provide a timezone
To achieve backwards compatibility and usability without JavaScript, the dates must be converted and rendered into pure HTML. This makes cURL a working target.
Progressive enhancement extends on the UI by providing a visual editor for timezones, dates and times that change the URL. This is done with JavaScript and native input elements. In the future custom input elements could replace the native ones.
## Timezone Specifiers
### `tzdata`
These are defined in the ICANN/IETF database. Examples:
- Asia/Kolkata (India)
- Asia/Singapore (Singapore)
- America/Mexico_City (Mexico)
- Asia/Saigon (Vietnam)
- America/Los_Angeles (Pacific)
### GeoNames
Sources:
- `cities15000.txt`
- `countryInfo.txt`
-

View File

@ -1,140 +0,0 @@
* {
box-sizing: border-box;
}
html {
height: 100%;
}
body {
margin: 0;
font-family: "Lora", "Didot", "Garamond", serif;
display: flex;
flex-direction: column;
min-height: 100%;
}
.list-inline {
list-style: none;
padding: 0;
}
.list-inline li {
display: inline-block;
}
.list-inline li:before {
content: "\2022";
padding: 0 0.25rem;
}
.list-inline li:first-child:before {
content: none;
}
main {
flex-grow: 1;
margin: 0 auto;
padding: 2rem 0.5rem;
width: 100%;
max-width: 50rem;
}
footer {
margin: 0 auto;
padding: 0.5rem 1.5rem;
width: 100%;
max-width: 50rem;
font-size: 0.75em;
opacity: 0.5;
text-align: right;
}
footer a {
color: inherit;
}
datetime-zone {
margin: 1rem;
padding: 1rem;
background: rgba(128, 128, 128, 0.25);
border-radius: 0.5rem;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
}
datetime-zoneinfo {
flex-grow: 1;
padding: 0.5rem;
width: 18rem;
display: flex;
flex-direction: column;
justify-content: center;
}
datetime-zonename {
display: block;
font-weight: bold;
}
datetime-zoneoffset {
display: block;
}
datetime-datetime {
flex-grow: 1;
width: 22rem;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-end;
align-items: center;
}
datetime-date,
datetime-time {
padding: 0.5rem;
font-size: 1em;
text-align: center;
}
datetime-date {
width: 11em;
}
datetime-time {
font-size: 1.5em;
width: 7em;
}
/*
datetime-date {
width: 10rem;
}
datetime-time {
width: 5rem;
}
*/
@media (max-width: 28rem) {
datetime-date,
datetime-time {
width: 100%;
}
}
@media (prefers-color-scheme: dark) {
html {
background: #000;
color: #fff;
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,70 +0,0 @@
package main
import (
"encoding/json"
"strings"
"encoding/xml"
"io/ioutil"
"log"
"net/http"
)
const timezoneXML = "https://raw.githubusercontent.com/unicode-org/cldr/master/common/bcp47/timezone.xml"
func main() {
resp, err := http.Get(timezoneXML)
if err != nil {
log.Fatalf("Failed to fetch: %v", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Failed to fetch: %v", err)
}
// Parse XML file
data := &ldmlData{}
err = xml.Unmarshal(body, &data)
if err != nil {
log.Fatalf("Failed to parse: %v", err)
}
// Remap into different format
timezonesData := make([]timezoneData, len(data.Keys))
for i, t := range data.Keys {
timezonesData[i] = timezoneData{
Name: t.Name,
Description: t.Description,
Aliases: strings.Split(t.Alias, " "),
}
}
// Encode JSON file
b, err := json.Marshal(timezonesData)
if err != nil {
log.Fatalf("Failed to encode: %v", err)
}
// Write JSON file
err = ioutil.WriteFile("js/bcp47timezone.json", b, 0644)
if err != nil {
log.Fatalf("Failed to write: %v", err)
}
}
type ldmlData struct {
Keys []ldmlType `xml:"keyword>key>type"`
}
type ldmlType struct {
Name string `xml:"name,attr"`
Description string `xml:"description,attr"`
Alias string `xml:"alias,attr"` // NOTE: space-separated values
}
type timezoneData struct {
Name string `json:"name"`
Description string `json:"description"`
Aliases []string `json:"aliases"`
}

View File

@ -5,7 +5,6 @@
<title>datetime.link</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&display=swap">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>