Skip to content

Add support for <!date> formatting command #131

@umar-ahmed

Description

@umar-ahmed

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions