Skip to content

Ordinal dates? #10

@mbostock

Description

@mbostock

Related d3/d3#495. TODO:

  • Decide on localizable implementation. (Locale-defined function.)
  • Decide on directive. (%o)
  • Implement formatting.
  • Implement padding.
  • Implement parsing.
  • Test.

This implementation works in English:

var suffixes = ["th", "st", "nd", "rd"];

function suffix(number) {
  var tail = number % 100;
  return suffixes[(tail < 11 || tail > 13) && (tail % 10)] || suffixes[0];
}

However, it’s not clear how we should localize this behavior. Perhaps the locale definition can include a JavaScript function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions