Added new time utility

This commit is contained in:
Louis Hollingworth 2022-05-23 20:37:02 +01:00
parent f2aef2012b
commit 26e91acd9c
No known key found for this signature in database
GPG key ID: 1E66DEA3F5D623D1
10 changed files with 224 additions and 57 deletions

View file

@ -1,2 +1,3 @@
$primary-colour-light: rgb(127, 127, 127);
$bg-colour-light: rgb(187, 187, 187); $bg-colour-light: rgb(187, 187, 187);
$accent-colour-light: rgb(24, 96, 231);
$filter-accent-colour-light: invert(34%) sepia(96%) saturate(4970%) hue-rotate(216deg) brightness(95%) contrast(91%);

View file

@ -7,13 +7,12 @@ body {
} }
.container { .container {
min-height: 100vh; min-height: 80vh;
padding: 0 0.5rem; padding: 0 0.5rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100vh;
} }
.title { .title {

View file

@ -21,7 +21,14 @@
color: #eaeaea; color: #eaeaea;
} }
.grid { .grid-2 {
display: grid;
align-items: center;
justify-content: center;
grid-template-columns: 1fr 1fr;
}
.grid-3 {
display: grid; display: grid;
align-items: center; align-items: center;
justify-content: center; justify-content: center;

View file

@ -1 +1 @@
8 9

View file

@ -34,6 +34,7 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@use '../assets/styles/colours';
.card { .card {
margin: 1rem; margin: 1rem;
padding: 1.5rem; padding: 1.5rem;
@ -58,8 +59,8 @@ export default {
.card:hover, .card:hover,
.card:focus, .card:focus,
.card:active { .card:active {
color: #0070f3 !important; color: colours.$accent-colour-light !important;
border-color: #0070f3; border-color: colours.$accent-colour-light;
} }
@media (max-width: 600px) { @media (max-width: 600px) {

View file

@ -1,23 +1,44 @@
<template> <template>
<nav> <nav>
<div v-for="link in links" :key="link"> <div v-for="link in links" :key="link">
<NuxtLink :to="link.to" class="nav-button"> <div class="nav-button">
<NuxtLink :to="link.to">
<img :src="link.img.name" :alt="link.img.alt" /> <img :src="link.img.name" :alt="link.img.alt" />
<p>{{ link.name }}</p>
</NuxtLink> </NuxtLink>
</div> </div>
</div>
</nav> </nav>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@use '../assets/styles/colours';
nav { nav {
margin: 0 auto;
position: -webkit-sticky;
position: sticky;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin-bottom: 1rem;
} }
nav :hover {
filter: colours.$filter-accent-colour-light;
}
nav a {
text-decoration: none;
color: black;
}
p {
padding: 0;
margin: 0;
}
.nav-button { .nav-button {
padding: .25rem; margin: 0 1rem;
margin: .25rem; padding: 0.5rem;
} }
</style> </style>

View file

@ -6,7 +6,7 @@
spaces. spaces.
</p> </p>
<strong>It's official! There is going to be another season!</strong> <strong>It's official! There is going to be another season!</strong>
<div class="grid"> <div class="grid-3">
<LinkCard <LinkCard
title="Watch" title="Watch"
to="https://www.netflix.com/title/81210762" to="https://www.netflix.com/title/81210762"

View file

@ -16,27 +16,23 @@
</div> </div>
</template> </template>
<script> <script setup>
export default { const navLinks = [
data() {
return {
navLinks: [
{ {
img: { img: {
name: '/icons/arrow-left.svg', name: '/icons/arrow-left.svg',
alt: 'Back to Utilities', alt: 'Back to Utilities',
}, },
to: '/utilities', to: '/utilities',
name: "Utilities",
}, },
{ {
img: { img: {
name: '/icons/home.svg', name: '/icons/home.svg',
alt: 'Home', alt: 'Go Home',
}, },
to: '/', to: '/',
name: "Home",
}, },
], ];
};
},
};
</script> </script>

View file

@ -2,24 +2,22 @@
<NavBar :links="navLinks" /> <NavBar :links="navLinks" />
<div class="container"> <div class="container">
<h1 class="title">Utilities for the Discord Server</h1> <h1 class="title">Utilities for the Discord Server</h1>
<div class="grid-2">
<LinkCard title="Birthdays" to="/utilities/birthdays" /> <LinkCard title="Birthdays" to="/utilities/birthdays" />
<LinkCard title="Time" to="/utilities/time" />
</div>
</div> </div>
</template> </template>
<script> <script setup>
export default { const navLinks = [
data() {
return {
navLinks: [
{ {
img: { img: {
name: '/icons/home.svg', name: '/icons/home.svg',
alt: 'Home', alt: 'Go Home',
}, },
to: '/', to: '/',
name: "Home",
}, },
], ];
};
},
};
</script> </script>

144
pages/utilities/time.vue Normal file
View file

@ -0,0 +1,144 @@
<template>
<NavBar :links="navLinks" />
<div class="container">
<h1 class="title">Time Utilities</h1>
<p>
Your current timezone:
{{ Intl.DateTimeFormat().resolvedOptions().timeZone }}
</p>
<p>The current time in Unix Epoch: <code>{{ Math.floor(crntTime / 1000) }}</code> <br /> or <code>{{crntTime}}</code> in Unix millis</p>
<p>
To format the time for Discord, you can use: <br />
<code>
{{ `<t:${Math.floor(crntTime / 1000)}:f>` }}
</code>
<span>
to get
<code
>{{
Intl.DateTimeFormat(Intl.Locale, {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(crntTime)
}}
{{
Intl.DateTimeFormat(Intl.Locale, {
hour: '2-digit',
minute: '2-digit',
}).format(crntTime)
}}</code
></span
>
<br />
<code>
{{ `<t:${Math.floor(crntTime / 1000)}:F>` }}
</code>
<span>
to get
<code
>{{
Intl.DateTimeFormat(Intl.Locale, {
weekday: 'long',
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(crntTime)
}}
{{
Intl.DateTimeFormat(Intl.Locale, {
hour: '2-digit',
minute: '2-digit',
}).format(crntTime)
}}</code
></span
>
<br />
<code>
{{ `<t:${Math.floor(crntTime / 1000)}:t>` }}
</code>
<span>
to get
<code>
{{
Intl.DateTimeFormat(Intl.Locale, {
hour: '2-digit',
minute: '2-digit',
}).format(crntTime)
}}</code
></span
>
<br />
<code>
{{ `<t:${Math.floor(crntTime / 1000)}:T>` }}
</code>
<span>
to get
<code>
{{
Intl.DateTimeFormat(Intl.Locale, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).format(crntTime)
}}</code
></span
>
<br />
<code>
{{ `<t:${Math.floor(crntTime / 1000)}:d>` }}
</code>
<span>
to get
<code>
{{
Intl.DateTimeFormat(Intl.Locale, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}).format(crntTime)
}}</code
></span
>
<br />
<code>
{{ `<t:${Math.floor(crntTime / 1000)}:D>` }}
</code>
<span>
to get
<code>
{{
Intl.DateTimeFormat(Intl.Locale, {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(crntTime)
}}</code
></span
>
</p>
</div>
</template>
<script setup>
const crntTime = Date.now();
const navLinks = [
{
img: {
name: '/icons/arrow-left.svg',
alt: 'Back to Utilities',
},
to: '/utilities',
name: 'Utilities',
},
{
img: {
name: '/icons/home.svg',
alt: 'Go Home',
},
to: '/',
name: 'Home',
},
];
</script>