FIX: Support for local-date email preview without time attribute
This commit is contained in:
parent
e3c6dd26c4
commit
bfa25487eb
|
@ -32,19 +32,20 @@ function addLocalDate(buffer, matches, state) {
|
|||
["data-timezones", state.md.utils.escapeHtml(config.timezones)]
|
||||
];
|
||||
|
||||
let dateTime = config.date;
|
||||
if (config.time) {
|
||||
token.attrs.push(["data-time", state.md.utils.escapeHtml(config.time)]);
|
||||
dateTime = `${dateTime} ${config.time}`;
|
||||
}
|
||||
|
||||
let dateTime;
|
||||
if (config.timezone) {
|
||||
token.attrs.push([
|
||||
"data-timezone",
|
||||
state.md.utils.escapeHtml(config.timezone)
|
||||
]);
|
||||
dateTime = moment.tz(`${config.date} ${config.time}`, config.timezone);
|
||||
dateTime = moment.tz(dateTime, config.timezone);
|
||||
} else {
|
||||
dateTime = moment.utc(`${config.date} ${config.time}`);
|
||||
dateTime = moment.utc(dateTime);
|
||||
}
|
||||
|
||||
if (config.recurring) {
|
||||
|
|
|
@ -11,5 +11,14 @@ describe PrettyText do
|
|||
HTML
|
||||
|
||||
expect(PrettyText.format_for_email(cooked)).to match_html(cooked_mail)
|
||||
|
||||
cooked = PrettyText.cook <<~MD
|
||||
[date=2018-05-08 format=LLL timezone="Europe/Berlin" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
MD
|
||||
cooked_mail = <<~HTML
|
||||
<p><span class="discourse-local-date" data-date="2018-05-08" data-format="LLL" data-timezones="Europe/Paris|America/Los_Angeles" data-timezone="Europe/Berlin" data-email-preview="May 8, 2018 12:00 AM (Europe: Paris)">May 8, 2018 12:00 AM (Europe: Paris)</span></p>
|
||||
HTML
|
||||
|
||||
expect(PrettyText.format_for_email(cooked)).to match_html(cooked_mail)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue