Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: date time formats from locales #4029

Merged
merged 21 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add: full time format
  • Loading branch information
YUCLing committed Oct 4, 2024
commit cd880d7a651eff69fc281e37092bc3a7c0d828ec
3 changes: 2 additions & 1 deletion framework/core/js/src/common/helpers/fullTime.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs';
import type Mithril from 'mithril';
import app from "../app";

/**
* The `fullTime` helper displays a formatted time string wrapped in a <time>
Expand All @@ -9,7 +10,7 @@ export default function fullTime(time: Date): Mithril.Vnode {
const d = dayjs(time);

const datetime = d.format();
const full = d.format('LLLL');
const full = app.translator.formatDateTime(d, "core.lib.datetime_formats.full_time");

return (
<time pubdate datetime={datetime}>
Expand Down
3 changes: 2 additions & 1 deletion framework/core/js/src/common/helpers/humanTime.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs';
import type Mithril from 'mithril';
import app from "../app";
import humanTimeUtil from '../utils/humanTime';

/**
Expand All @@ -11,7 +12,7 @@ export default function humanTime(time: Date): Mithril.Vnode {
const d = dayjs(time);

const datetime = d.format();
const full = d.format('LLLL');
const full = app.translator.formatDateTime(d, "core.lib.datetime_formats.full_time");
const ago = humanTimeUtil(time);

return (
Expand Down
1 change: 1 addition & 0 deletions framework/core/locale/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ core:

# These are DayJS formats used in core.
datetime_formats:
full_time: LLLL
human_time_short: D MMM
human_time_full: ll
post_stream_scrubber: MMMM YYYY
Expand Down
Loading