Ordinal dates?

Open
#10 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript

Research direction

Read the related d3/d3#495 issue and this repository’s locale and directive implementation to understand how locale-specific ordinal formatting should work. The issue leaves the localization design open and lists formatting, padding, parsing, and tests as unfinished; done means resolving that design and implementing and testing the %o directive.

Written by the indexing model from the issue text.

Description

Related mbostock/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?

Dominant language
JavaScript
Stars
338
Forks
100
Avg merge
6h 20m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from d3/d3-time-format

All issues in d3/d3-time-format

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.