Skip to content

Conversation

@DZittersteyn
Copy link

Both dictionary.com and wikipedia recognize 0th or zeroth, which makes this special case a bit weird to me

@FranDias
Copy link

FranDias commented Jul 7, 2016

Thank you for the careful thought and consideration as well as your time and effort into this pull request. Just because a word is defined does not make it colloquial. As a native speaker I cannot think of a case where zeroth makes sense in conversation.

Anything in the place of zeroth, to my mind, spoken still seems like it should be "first". Which we cannot guarantee is correct. I'll continue looking for an example where this is correct until tomorrow.

Unless we think of an example of a reasonable use case I'm closing this. Thanks again for your thought and time.

@FranDias FranDias closed this Jul 7, 2016
@DZittersteyn
Copy link
Author

No worries, I was using this to ordinalize percentiles from postgres' NTILE method, and after actually reading the documentation, NTILE returns an "integer ranging from 1 to the argument value", so the 0 case will never get hit.

0th or zeroth are mostly in use in CompSci and Mathematics, as far as I can tell, so I might be suffering from a 'slight' bias here ;). Some examples from those fields:

  • Zeroth-order logic is first-order logic without variables or quantifiers src
  • Under zero-based numbering, the initial element is sometimes termed the zeroth element, rather than the first element src
  • the zeroth power of a number src

The last one of those even says as much:

the word, which was coined by physicists over a hundred years ago, does often show up in scientific contexts

Anyhoo, I completely defer to you here, since I no longer have a horse in the race here.

@FranDias
Copy link

FranDias commented Jul 7, 2016

Thanks! dI'l be happy to revisit and have a conversation it it covers up again.

@geekjuice
Copy link
Contributor

geekjuice commented Jul 7, 2016

I think this use case makes sense in those context. My suggestion would be to to extend .ordinal to take a second, optional parameter that allows for 0th if it's being used for e.g. scientific humanization. For example:

ordinal(value, options = {}) {
  const { scientific = false } = options; // Maybe a better name...
  const number = parseInt(value, 10);

  if (number === 0 && !scientific) {
    return value;
  }

  ...
}

This behavior should definitely be opt-in though and by default should use the current humanization.

@geekjuice geekjuice reopened this Jul 7, 2016
@FranDias
Copy link

FranDias commented Jul 7, 2016

+1

@DZittersteyn
Copy link
Author

DZittersteyn commented Jul 7, 2016

I added a zeroth option, not sure if that's better or worse than scientific though ;)

currently adding docs for the option

});

it('should return the input if the number is 0', () => {
expect(Humanize.ordinal('0.')).toEqual('0.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the method should be updated to return the string version of the parsed input rather than the original input.

expect(Humanize.ordinal(0)).toEqual('0');

// and 

expect(Humanize.ordinal('0.foobar')).toEqual('0');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to me, since ordinal(1.foo) returns 1st, not 1.foost. It would however be somewhat of an backwards incompatible change, so I'll shoot in a separate PR for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants