question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plurals vs singulars in ordinals

See original GitHub issue

This issue is for gathering inputs from people with an intuitive understanding of English to help us name things.

Preliminaries: we have Instant.epochSeconds, which returns the number of seconds that passed since the Unix epoch. On the epoch itself and after some number of nanoseconds that don’t amount to a whole second, Instant.epochSeconds returns 0.

Other libraries, like java.time, provide the same functionality, but with a slightly different name: Instant.epochSecond (note it being singular). We assume that the idea behind this is “the nth second since the epoch”.

However, colloquially, the nth second/etc. is the second/etc. that goes on before n whole seconds/etc. have passed. For example, January is the first month of the year, that is, the month that goes on before a whole month has passed.

Questions for the readers:

  • If you see Instant.epochSecond == 1, what do you think it means—does it mean that it is the first second since the start of the epoch, or that 1 full second has passed since then?
  • The same, but about Instant.epochSeconds. Does this naming seem natural, or slightly odd?
  • The same about LocalTime.secondOfDay and LocalTime.secondsOfDay: do they mean the same thing to you, or do you feel the first one is an ordinal, but the second one is the count?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cpovirkcommented, May 26, 2022

I recall giving some thought to this in designing some of our own time-related APIs. I don’t recall all the details, but I like the look of the post above, which reminds me of this comment from Stephen Colebourne and this other comment from Stephen Colebourne.

My take, which I think may be compatible with the previous post, but I am confusing myself as I dig through old links… 😃

  • Instant.epochSecond == 1: a full second has passed
  • Instant.epochSeconds == 1: probably still that, but I think I’d prefer the singular, and I might expect the plural to return a floating-point number
  • LocalTime: same answers, and I’d prefer singular even more, since theoretically someone could expect “secondsOfDay” to return the total number of seconds in that day (which isn’t something that a LocalTime or even a LocalDateTime could answer, of course, but someone might expect it to)

My understanding is that the java.time people consistently used the singular for the fields of LocalTime-like objects and erred only in accidentally also using it for the one of the fields of Duration, which should have used plural. And I think that’s a good way to go.

[edit: one other link]

1reaction
PeterAttardocommented, May 27, 2022

I think something else that’s worth noting is that in all cases where a 0 value exists, the unit is 0-indexed. The time components all have a :00 value, so they are all 0-indexed. Whereas there is no 0th month, 0th day of the week, or 0th year on the calendar, so they are 1-indexed. Admittedly this is a bit of a tautology, but it’s still instructive. If 0 is a valid value for secondOfEpoch, then I think that would imply it should be 0-indexed as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ordinal number - Wiktionary
If an ordinal is followed by a plural noun, the two-word phrase refers to a set of items described by the phrase in...
Read more >
What is the plural of ordinal number? - WordHippo
The plural form of ordinal number is ordinal numbers. Find more words!
Read more >
Ordinal Numbers - StudySpanish.com
Like many other adjectives, the ordinal numbers have a masculine and a feminine form. They also have a singular and plural form. So,...
Read more >
Support of plural forms for cardinal and ordinal numerals
In English, a noun that refers to cardinal numerals is declined only according to numbers (1 day, 2 days), and there are four...
Read more >
Declension of Cardinals and Ordinals
Cardinal and Ordinal Numbers ... The plural is used in this sense; but also, as a simple numeral, to agree with a plural...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found