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

Add support for <!date> formatting command #131

Open
umar-ahmed opened this issue Jan 29, 2024 · 0 comments
Open

Add support for <!date> formatting command #131

umar-ahmed opened this issue Jan 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@umar-ahmed
Copy link

Is your feature request related to a problem? Please describe.

I see that there are helpers for formatting Markdown, which is awesome! Wondering if you'd consider supporting Slack's advanced formatting, specifically Date formatting?

Describe the solution you'd like

I think exposing something like Md.date() would be useful to format dates.

Describe alternatives you've considered

I've implemented my own helper in my codebase, but it only exposes a narrow subset of the formatting options Slack allows:

import { DateTime } from "luxon";

const date = (date: Date) => {
  const datetime = DateTime.fromJSDate(date);
  const unixTimestamp = datetime.toFormat("X");
  const fallback = datetime.toFormat("MMMM d, yyyy 'at' h:mm a 'UTC'");
  return `<!date^${unixTimestamp}^{date} at {time}|${fallback}>`;
};

Additional context

  • It may be costly to add a dependency for dealing with dates (Temporal API is Stage 3, but not adopted yet by any runtimes except Deno)
  • There's a lot of options for formatting the result and it might be challenging to explain to devs
  • On the plus side, these dates are timezone aware and will display information in a more robust way!
@umar-ahmed umar-ahmed added the enhancement New feature or request label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant