Skip to content

Commit

Permalink
removing date formatting functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
HarukaYamamoto0 committed Mar 28, 2024
1 parent 06c6754 commit e0b7bda
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 51 deletions.
Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 9 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
<title>Timestamp Generator and Converter</title>
<meta
name="description"
content="Take the current timestamp, convert it to a date, or even convert a date to a timestamp"
content="Get the current timestamp or see the date it represents."
/>
<meta
name="keywords"
content="timestamp, converter, date, timestamp generator, timestamp to date, date to timestamp"
/>
<meta name="author" content="HarukaYamamoto0" />
<meta name="robots" content="index, follow" />
<meta name="language" content="English" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand All @@ -18,7 +25,7 @@
</head>
<body>
<header>
<h1>Converter and timestamp generator</h1>
<h1>Timestamp Converter</h1>
</header>
<main>
<section id="section-get-current-timestamp">
Expand Down Expand Up @@ -59,32 +66,6 @@ <h2>Convert Timestamp To Date</h2>
</span>
</button>
</section>

<div class="divider"></div>

<section id="section-convert-date-to-timestamp">
<h2>Convert Date to Timestamp</h2>
<input
id="input-convert-date-to-timestamp"
class="input"
type="text"
placeholder="YYYY-MM-DD hh:mm:ss p.m."
/>
<button
onclick="convertDateToTimestamp()"
class="action-button convert-to-timestamp-button"
>
Convert!
</button>
<button class="result-button">
<span id="result-button-convert-date-to-timestamp" class="result-text"
>1695938792</span
>
<span class="icons">
<img src="./assets/clipboard.svg" />
</span>
</button>
</section>
</main>
<script src="scripts.js"></script>
</body>
Expand Down
26 changes: 4 additions & 22 deletions scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,15 @@ function convertTimestampToDate(timestamp) {
"input-convert-timestamp-to-date",
);

const date = new Date(parseInt(timestampInput.value) * 1000);
const localizedDate = date.toLocaleString().replace(",", "");
const date = new Date(parseInt(timestamp || timestampInput.value) * 1000);
const localizedDate = date
.toLocaleString("sv", { timeZoneName: "short" })
.replace(",", "");

resultButton.textContent = localizedDate;
return localizedDate;
}

function convertDateToTimestamp() {
const resultButton = document.getElementById(
"result-button-convert-date-to-timestamp",
);
const timestampInput = document.getElementById(
"input-convert-date-to-timestamp",
);

const formattedDate = new Date(
timestampInput.value.replace("p.m.", "PM").replace("a.m.", "AM"),
);
const timestamp = formattedDate.getTime() / 1000;

if (Number.isNaN(timestamp)) {
return alert("Please enter a valid date!");
}

resultButton.textContent = timestamp;
}

const resultButtons = document.querySelectorAll(".result-button");

resultButtons.forEach((button) => {
Expand Down
3 changes: 2 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}

body {

font-family: "Ubuntu Mono", monospace;
font-weight: 400;
font-style: normal;
Expand All @@ -36,7 +37,7 @@ header {

main {
padding: 10vw;
padding-top: 4vh;
padding-top: 5vh;
display: flex;
flex-direction: column;
justify-content: center;
Expand Down

0 comments on commit e0b7bda

Please sign in to comment.