NAME

Slack::BlockKit::Block::RichText::Date - a Block Kit rich text element for a formatted date

VERSION

version 0.002

OVERVIEW

This represents a date element in Block Kit, which takes a unix timestamp and displays it in a format appropriate for the reader.

Be warned! The element is not documented in the Block Kit documentation, but Slack support disclosed its existence. They said it was just missing documentation, but might it just go away? Who can say.

PERL VERSION

This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

ATTRIBUTES

timestamp

This is the date (and time) that you want to format, which will be formatted into the reader's own time zone when displayed. It is required, and must be a unix timestamp. (That is: a number of seconds since 1970, as per "time" in perlfunc.

format

This is the format string to be used formatting the timestamp. Because the date rich text element isn't documented in the Block Kit docs (currently), you'll want to find the format specification in the "Formatting text for app surfaces" docs.

Something like this is plausible:

"{date_short_pretty}, {time}"

Probably because of the date element's origin in mrkdwn, it has the odd property that the first character will be capitalized. To suppress this, you can prefix your format string with U+200B, the zero-width space. For example:

"\x{200b}{date_short_pretty}, {time}"

This is done, by default, in Slack::BlockKit::Sugar's date function.

fallback

If given, and if the client can't process the given date, this string will be displayed instead. If you put a pre-formatted date string in this, include the time zone, because the reader will expect that it will have been localized.

url

If given, the formatted date string will also be a link to this URL.

AUTHOR

Ricardo SIGNES <rjbs@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Ricardo SIGNES.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.