forked from hodcroftlab/covariants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hodcroftlab#134 from hodcroftlab/feat/last-updated
- Loading branch information
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"lastUpdated": "2021-03-24T14:45:58.499739"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { HTMLProps } from 'react' | ||
import styled from 'styled-components' | ||
import classNames from 'classnames' | ||
|
||
import { getLastUpdatedDate, getLastUpdatedFull } from 'src/io/getLastUpdatedDate' | ||
|
||
const LAST_UPDATED_DATE = `Last updated: ${getLastUpdatedDate()}` | ||
const LAST_UPDATED_FULL = `Last updated on: ${getLastUpdatedFull()}` | ||
|
||
const LastUpdatedText = styled.small` | ||
font-size: 0.9rem; | ||
` | ||
|
||
export function LastUpdated({ className }: HTMLProps<HTMLParagraphElement>) { | ||
return ( | ||
<LastUpdatedText className={classNames(className)}> | ||
<span className="ml-1" title={LAST_UPDATED_FULL}> | ||
{LAST_UPDATED_DATE} | ||
</span> | ||
</LastUpdatedText> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { lastUpdated } from 'src/../data/update.json' | ||
|
||
import { DateTime } from 'luxon' | ||
|
||
export function getLastUpdatedDate() { | ||
const utc = DateTime.fromISO(lastUpdated, { zone: 'UTC' }) | ||
const local = utc.toLocal() | ||
return local.toISODate() | ||
} | ||
|
||
export function getLastUpdatedFull() { | ||
const utc = DateTime.fromISO(lastUpdated, { zone: 'UTC' }) | ||
const local = utc.toLocal() | ||
return `${local.toJSDate().toLocaleString()} (${local.zoneName})` | ||
} |