A mathematician would probably find the imprecision of precise orbital time a little frustrating.
A second can be defined as
"the duration of 9,192,631,770 periods of the radiation corresponding
to the transition between the two hyperfine levels of the ground state
of the caesium 133 atom"
A 24 hour day is 86,400 of those, well, more or less.
A problem that early time-keepers ran into was that the length of the day varied based on the time of year. Earth does a complete rotation in about 23 hours, 56 minutes, so, the rotation really doesn't factor into it directly, but because Earth orbits the sun about 1 degree of arc every 24 hours, an apparent solar day is has been defined as 24 hours long for centuries. Days are shorter than that when the earth is closer to the sun, at perihelion, (by about 20 seconds) and days are longer than the 24 hour average by about 30 seconds at aphelion. Not enough for anyone to notice unless they were measuring solar time very precisely.
So a day has to be averaged out, called a mean solar day, and that's what 24 hours was based on. The problem is, Earth's rotation is slowing down. The Moon is very gradually slowing down the rotation of the Earth by tidal interaction, so an average day is currently about 86,400.002 seconds. Leap seconds are added almost every year and in the future, leap seconds will be added more often. Officially a day is still 86,400 seconds, and when a leap-second is added, the "leap-day" is 86,401 seconds. But you could use either number for number of days in a year, average day (currently 86,400.002) or SI day* (86,400). As I understand it, a year is usually measured in 86,400 second days or SI days, not "average" days, but it's important to be specific about which one you're using. I've seen the occasional article that says that 200 million years ago a year was about 400 days long. That's clearly using average says, not SI days.
And if you live in high altitude, your clock will run even faster and a day will run a tiny bit longer thanks to relativity but . . . lets not even go there for the calculations).
A solar year, based on the position of the sun and the precise time of the solstice of your choice, which is a precise and momentary alignment. The length of a solar year changes a bit on a year-to-year basis. The position of the moon and gravitational perturbations from other planets, affect Earth's period of rotation a little bit, so like the day, the year should be averaged out also. Modern leap-year calendars adjust days to years quote well, but not to the accuracy you're asking about.
Looking at the time of recent summer solstices (I've copied them down below for the June solstice).
There's as much as 15 minutes variation in the length of a year over this 11 year sample. That's not because Earth's orbit is permanently changing. These are mostly fluctuations due to the Moon and nearby planets.
An "average year", or mean tropical year, is currently about 365.2422 86,400 second days and if you want to get more accurate, 365.2421897 days on January 1, 2000. Formula in the link for adjusting to different years.
I suspect, but I'm not 100% certain that the Earth's mean tropical year moves back and forth with some of Earth's Milankovich cycles. It's not slowing consistently in the sense that a day is slowing due to the Moon's gravity and inverse tidal force.
According to Kepler's laws, the orbital period is based mostly on Earth's semi-major axis. The problem is that Kepler's laws aren't 100% accurate. Relativity is a factor when you try to pinpoint a year precisely to the second and variation in eccentricity, which affects Earth's orbital speed and the precise timing of an average year.
What I know about orbital stability, is that Earth's semi-major axis changes very little, even during the Milankovich cycles, and orbital projections say, that it will probably change little even over time-frames of millions of years.
The Sun is also losing mass, which should slow the Earth's orbit over time, but that effect is also very tiny. Over millions of years, it's thought that the length of a year doesn't change very much. The length of a day, over time-periods that long, changes quite a bit more rapidly. An unanticipated orbital change is always possible, but not thought to be likely. Orbits don't leave much in the way of track-able footprints, so they're hard to pinpoint over long periods of time and are mostly estimated by mathematical models so, take with a grain of salt, but models do suggest that a year is pretty much constant even over periods of millions of years.
For further reading, maybe start here: https://en.wikipedia.org/wiki/Equation_of_time
Hope that helps. Some of the math gets kinda tricky.
- Thanks zephyr. I wasn't familiar with that term.