Closed Bug 1839691 Opened 3 years ago Closed 1 year ago

Share code to generate date-time strings in Temporal

Categories

(Core :: JavaScript: Standard Library, task, P3)

task

Tracking

()

RESOLVED DUPLICATE of bug 1847182

People

(Reporter: anba, Unassigned)

References

(Blocks 1 open bug)

Details

Date-time strings are currently directly written into a JSStringBuilder, maybe a helper class should be added to avoid repeating code like this one in multiple places:

if (0 <= year && year <= 9999) {
  result.infallibleAppend(char('0' + (year / 1000)));
  result.infallibleAppend(char('0' + (year % 1000) / 100));
  result.infallibleAppend(char('0' + (year % 100) / 10));
  result.infallibleAppend(char('0' + (year % 10)));
} else {
  result.infallibleAppend(year < 0 ? '-' : '+');

  year = std::abs(year);
  result.infallibleAppend(char('0' + (year / 100000)));
  result.infallibleAppend(char('0' + (year % 100000) / 10000));
  result.infallibleAppend(char('0' + (year % 10000) / 1000));
  result.infallibleAppend(char('0' + (year % 1000) / 100));
  result.infallibleAppend(char('0' + (year % 100) / 10));
  result.infallibleAppend(char('0' + (year % 10)));
}
Severity: -- → N/A
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1847182
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.