Skip to content

Commit d43737c

Browse files
committed
Use tropical years as 'year' unit
We follow GNU units and Frink here and use the mean tropical year for the `year` unit. See `numbat/modules/units/time.nbt` for details. The Gregorian year is still available as `gregorian_year`. closes #321
1 parent 0e887c7 commit d43737c

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

book/src/list-units.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ and — where sensible — units allow for [binary prefixes](https://en.wikipedi
171171
| `Time` | [Day](https://en.wikipedia.org/wiki/Day) | `d`, `day`, `days` |
172172
| `Time` | [Decade](https://en.wikipedia.org/wiki/Decade) | `decade`, `decades` |
173173
| `Time` | [Fortnight](https://en.wikipedia.org/wiki/Fortnight) | `fortnight`, `fortnights` |
174+
| `Time` | [Gregorian year](https://en.wikipedia.org/wiki/Gregorian_year) | `gregorian_year`, `gregorian_years` |
174175
| `Time` | [Hour](https://en.wikipedia.org/wiki/Hour) | `h`, `hour`, `hours`, `hr` |
175176
| `Time` | [Julian year](https://en.wikipedia.org/wiki/Julian_year_(astronomy)) | `julian_year`, `julian_years` |
176177
| `Time` | [Millennium](https://en.wikipedia.org/wiki/Millennium) | `millennia`, `millennium` |
@@ -181,7 +182,7 @@ and — where sensible — units allow for [binary prefixes](https://en.wikipedi
181182
| `Time` | [Sidereal day](https://en.wikipedia.org/wiki/Sidereal_time#Sidereal_day) | `sidereal_day`, `sidereal_days` |
182183
| `Time` | [Stoney time](https://en.wikipedia.org/wiki/Stoney_units) | `stoney_time` |
183184
| `Time` | [Week](https://en.wikipedia.org/wiki/Week) | `week`, `weeks` |
184-
| `Time` | [Gregorian year](https://en.wikipedia.org/wiki/Gregorian_year) | `year`, `years`, `yr` |
185+
| `Time` | [Tropical year](https://en.wikipedia.org/wiki/Tropical_year) | `tropical_year`, `tropical_years`, `year`, `years`, `yr` |
185186
| `Velocity` | [Knot](https://en.wikipedia.org/wiki/Knot_(unit)) | `kn`, `knot`, `knots`, `kt` |
186187
| `Velocity` | [Kilometres per hour](https://en.wikipedia.org/wiki/Kilometres_per_hour) | `kph` |
187188
| `Velocity` | [Miles per hour](https://en.wikipedia.org/wiki/Miles_per_hour) | `mph` |

examples/consistency_others.nbt

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ assert_eq(1 min, 60 s)
1212
assert_eq(1 hour, 60 min)
1313
assert_eq(1 week, 7 day)
1414
assert_eq(1 day, 24 hour)
15-
assert_eq(1 month, 730.485 hour)
16-
assert_eq(1 year, 365.2425 day)
17-
assert_eq(1 year, 12 months)
15+
assert_eq(1 month, 730.485 hour, 0.001 hour)
16+
assert_eq(1 gregorian_year, 365.2425 day)
1817
assert_eq(1 julian_year, 365.25 day)
18+
assert_eq(1 year, 1 tropical_year)
1919

2020
assert_eq(1 gallon, 231 inch³, 1e-5 inch³)
2121
assert_eq(8 pint, 1 gallon)

examples/workhours.nbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ let duration = 0.5 year
2121
print(3 FTE * 0.5 years -> workdays)
2222
print(budget / rate / duration -> FTE)
2323
assert_eq(3 FTE * 0.5 years -> workdays, 300 workday)
24-
assert_eq(budget / rate / duration -> FTE, 5 FTE)
24+
assert_eq(budget / rate / duration -> FTE, 5 FTE, 1e-6 FTE)

numbat/modules/units/time.nbt

+30-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
use units::si
22

3-
### Time units
4-
53
@name("Week")
64
@url("https://en.wikipedia.org/wiki/Week")
75
@aliases(weeks)
86
unit week: Time = 7 days
97

10-
@name("Gregorian year")
11-
@url("https://en.wikipedia.org/wiki/Gregorian_year")
8+
# The mean tropical year changes over time (half a second per century). It's current
9+
# value can be approximated using
10+
#
11+
# 365.2421896698 - 6.15359e-6 T - 7.29e-10 T^2 + 2.64e-10 T^3
12+
#
13+
# where T is in Julian centuries, measured from noon January 1st, 2000.
14+
# (https://en.wikipedia.org/wiki/Tropical_year#Mean_tropical_year_current_value)
15+
#
16+
# Values of the mean tropical year for the recent past and near future:
17+
#
18+
# Year Length (days)
19+
# ---------------------
20+
# 2020 365.242 189 7
21+
# 2025 365.242 188 1
22+
# 2050 365.242 186 6
23+
#
24+
# For now, we use the 2025 value as a hardcoded constant. Those numbers
25+
# are mainly shown to illustrate that it is not sensible to define this
26+
# number more precise.
27+
#
28+
@name("Tropical year")
29+
@url("https://en.wikipedia.org/wiki/Tropical_year")
1230
@metric_prefixes
13-
@aliases(years, yr: short)
14-
unit year: Time = 365.2425 days
31+
@aliases(years, yr: short, tropical_year, tropical_years)
32+
unit year: Time = 365.242_188_1 days
1533

1634
@name("Month")
1735
@url("https://en.wikipedia.org/wiki/Month")
1836
@aliases(months)
1937
unit month: Time = year / 12
2038

39+
@name("Gregorian year")
40+
@url("https://en.wikipedia.org/wiki/Gregorian_year")
41+
@metric_prefixes
42+
@aliases(gregorian_years)
43+
unit gregorian_year: Time = 365.2425 days
44+
2145
@name("Julian year")
2246
@url("https://en.wikipedia.org/wiki/Julian_year_(astronomy)")
2347
@aliases(julian_years)

0 commit comments

Comments
 (0)