Time Zones Are Hard - https://tz.rita.moe

Add UTC in popular; Change CSS to make table

Having the last line not horizontally centered bothers me.
So let's use flexbox this time!

+1 -1
css/styles.css
···
-
body{background-color:#efefef;color:#000;font-family:"Trebuchet MS","Lucida Sans Unicode","Lucida Grande","Lucida Sans",Arial,sans-serif;margin:0 auto;max-width:900px}header{background:#fff;border-radius:10px;margin:1rem .5rem 0;padding:1rem 1.5rem}header h1{font-size:1.5rem;margin:0}@media screen and (min-width: 500px){header h1{font-size:2rem}}header a{color:inherit;text-decoration:none}main{padding:1rem 2rem}main h2{font-size:1.5rem;margin:1rem 0;text-align:center}main h2 span{font-size:1.2rem}main form{line-height:2rem}main button{cursor:pointer}main .tz-table{column-gap:1rem;display:grid;grid-template-columns:repeat(1, 1fr);row-gap:1rem;text-align:center}@media screen and (min-width: 440px){main .tz-table{grid-template-columns:repeat(2, 1fr)}}@media screen and (min-width: 630px){main .tz-table{grid-template-columns:repeat(3, 1fr)}}@media screen and (min-width: 820px){main .tz-table{grid-template-columns:repeat(4, 1fr)}}footer{color:gray;font-size:.7rem;margin-top:1rem;padding:1rem;text-align:center}@media screen and (prefers-color-scheme: dark){body{background-color:#111;color:#fff}header{background:#000}}/*# sourceMappingURL=styles.css.map */
···
+
body{background-color:#efefef;color:#000;font-family:"Trebuchet MS","Lucida Sans Unicode","Lucida Grande","Lucida Sans",Arial,sans-serif;margin:0 auto;max-width:900px}header{background:#fff;border-radius:10px;margin:1rem .5rem 0;padding:1rem 1.5rem}header h1{font-size:1.5rem;margin:0}@media screen and (min-width: 500px){header h1{font-size:2rem}}header a{color:inherit;text-decoration:none}main{padding:1rem 2rem}main h2{font-size:1.5rem;margin:1rem 0;text-align:center}main h2 span{font-size:1.2rem}main form{line-height:2rem}main button{cursor:pointer}main .tz-table{display:flex;flex-wrap:wrap;justify-content:center;text-align:center}main .tz-table .tz-table-element{flex:0 0 calc(100% - 1rem);margin:1rem .5rem}@media screen and (min-width: 440px){main .tz-table .tz-table-element{flex:0 0 calc(50% - 1rem)}}@media screen and (min-width: 630px){main .tz-table .tz-table-element{flex:0 0 calc(33% - 1rem)}}@media screen and (min-width: 820px){main .tz-table .tz-table-element{flex:0 0 calc(25% - 1rem)}}footer{color:gray;font-size:.7rem;margin-top:1rem;padding:1rem;text-align:center}@media screen and (prefers-color-scheme: dark){body{background-color:#111;color:#fff}header{background:#000}}/*# sourceMappingURL=styles.css.map */
+1 -1
css/styles.css.map
···
-
{"version":3,"sourceRoot":"","sources":["styles.scss"],"names":[],"mappings":"AAAA,KACE,yBACA,WACA,gGACA,cACA,gBAGF,OACE,gBACA,mBACA,oBACA,oBAEA,UACE,iBACA,SAEA,qCAJF,UAKI,gBAIJ,SACE,cACA,qBAIJ,KACE,kBAEA,QACE,iBACA,cACA,kBAEA,aACE,iBAIJ,UACE,iBAGF,YACE,eAGF,eACE,gBACA,aACA,qCACA,aACA,kBAEA,qCAPF,eAQI,sCAGF,qCAXF,eAYI,sCAGF,qCAfF,eAgBI,sCAKN,OACE,WACA,gBACA,gBACA,aACA,kBAGF,+CACE,KACE,sBACA,WAGF,OACE","file":"styles.css"}
···
+
{"version":3,"sourceRoot":"","sources":["styles.scss"],"names":[],"mappings":"AAAA,KACE,yBACA,WACA,gGACA,cACA,gBAGF,OACE,gBACA,mBACA,oBACA,oBAEA,UACE,iBACA,SAEA,qCAJF,UAKI,gBAIJ,SACE,cACA,qBAIJ,KACE,kBAEA,QACE,iBACA,cACA,kBAEA,aACE,iBAIJ,UACE,iBAGF,YACE,eAGF,eACE,aACA,eACA,uBACA,kBAIA,iCACE,2BACA,kBAEA,qCAJF,iCAKI,2BAGF,qCARF,iCASI,2BAGF,qCAZF,iCAaI,2BAMR,OACE,WACA,gBACA,gBACA,aACA,kBAGF,+CACE,KACE,sBACA,WAGF,OACE","file":"styles.css"}
+21 -15
css/styles.scss
···
}
.tz-table {
-
column-gap: 1rem;
-
display: grid;
-
grid-template-columns: repeat(1, 1fr);
-
row-gap: 1rem;
text-align: center;
-
-
@media screen and (min-width: 440px) {
-
grid-template-columns: repeat(2, 1fr);
-
}
-
-
@media screen and (min-width: 630px) {
-
grid-template-columns: repeat(3, 1fr);
-
}
-
-
@media screen and (min-width: 820px) {
-
grid-template-columns: repeat(4, 1fr);
}
}
}
···
}
.tz-table {
+
display: flex;
+
flex-wrap: wrap;
+
justify-content: center;
text-align: center;
+
+
$vertical-spacing: 1rem;
+
+
.tz-table-element {
+
flex: 0 0 calc(100% - $vertical-spacing);
+
margin: 1rem calc($vertical-spacing / 2);
+
+
@media screen and (min-width: 440px) {
+
flex: 0 0 calc(50% - $vertical-spacing);
+
}
+
+
@media screen and (min-width: 630px) {
+
flex: 0 0 calc(33% - $vertical-spacing);
+
}
+
+
@media screen and (min-width: 820px) {
+
flex: 0 0 calc(25% - $vertical-spacing);
+
}
}
}
}
+5 -4
index.php
···
'Asia/Dubai',
'Asia/Bangkok',
'Asia/Tokyo',
-
'Australia/Sydney'
];
// Micro-routing
···
<h3>In popular time zones</h3>
<div class="tz-table">
<?php foreach($popTZ as $tz) { ?>
-
<div>
<strong>
<?= str_replace('_', ' ', explode('/', $tz, 2)[1]) ?> (<?= getOffset($tz) ?>)
</strong>
···
</script>
<?php } else { ?>
<p>
-
Fill out this form to make a page that shows a set date and time in the visitor's time zone.
It will also show the time in other popular time zones.
</p>
<form action="/" method="post">
<label for="datetime">Date and Time:</label>&nbsp;
-
<input required type="datetime-local" id="datetime" name="datetime" />
<br/>
···
'Asia/Dubai',
'Asia/Bangkok',
'Asia/Tokyo',
+
'Australia/Sydney',
+
'UTC'
];
// Micro-routing
···
<h3>In popular time zones</h3>
<div class="tz-table">
<?php foreach($popTZ as $tz) { ?>
+
<div class="tz-table-element">
<strong>
<?= str_replace('_', ' ', explode('/', $tz, 2)[1]) ?> (<?= getOffset($tz) ?>)
</strong>
···
</script>
<?php } else { ?>
<p>
+
Fill out this form to make a page that shows a set date and time in the visitor's time zone.<br/>
It will also show the time in other popular time zones.
</p>
<form action="/" method="post">
<label for="datetime">Date and Time:</label>&nbsp;
+
<input required type="datetime-local" id="datetime" name="datetime"/>
<br/>
+1 -1
routing.php
···
<?php
-
// Use this with the local PHP server for development
// php -S 127.0.0.1:8080 routing.php
// Check static file
···
<?php
+
// Use this with the built-in PHP server
// php -S 127.0.0.1:8080 routing.php
// Check static file