Coder Social home page Coder Social logo

hifitime's People

Contributors

christopherrabotin avatar cjordan avatar conradludgate avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar ethanmsl avatar gwbres avatar karpfediem avatar mkolopanis avatar patricklucas avatar simpsoneric avatar striezel avatar supercilex avatar thomasantony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hifitime's Issues

ClockNoise incorrect

ClockNoise takes the span as the mean, but that's wrong. The mean of a clock is always zero. The span over which it is defined changes the ppm value.

Python library

Following the PyO3 user guide, I shall make a Python package out of hifitime. This will significantly help using this from Python and other libraries.

Instant should also implement TimeSystem (if possible)

If a type parameter is a TimeSystem, then one ought to be able to pass it a Datetime or a ModifierJulian or an Instant (sicne the Instant represents an atomic unit of time). This would prevent the following errors:

error[E0277]: the trait bound `od::hifitime::datetime::Instant: od::hifitime::TimeSystem` is not satisfied
  --> src/od/ranging.rs:50:23
   |
50 |         let tx_ecef = State::<ECEF>::from_geodesic(self.latitude, self.longitude, self.height, dt);
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `od::hifitime::TimeSystem` is not implemented for `od::hifitime::datetime::Instant`
   |
note: required by `<celestia::state::State<celestia::frames::ECEF>>::from_geodesic`
  --> src/celestia/state.rs:600:5
   |
600|     pub fn from_geodesic<T: TimeSystem>(latitude: f64, longitude: f64, height: f64, dt: T) -> State<ECEF> {

ClockNoise to include frequency and timing

Currently ClockNoise only does a timing random walk. However, it should also provide a way to sample a frequency (e.g. what could 2.3 GHz be with this clock).

The PPM should represent a value of seven sigma (effectively a perfect measurement).

Also separate the random walk method, from the frequency sample and the timing sample.

Note that a standard spacecraft clock is about 2 PPM. A high precision ground clock is in PPBs.

Add simulation module

The simulation module should include clock drift handling (likely via the new offset system).

Modified Julian helpers

  • Centuries since J2000 (used for a lot of Earth fixed computations)
  • More constants
  • Re-Exports to avoid having to import over three lines every time

More multiplication of units of time

This should support doing:

  • 1.0 * TimeUnit::Hour.
  • TimeUnit::Hour / 3

Also add documentation on TimeSeries. It took me a minute to figure it just weeks after 2.0 was released.

Initialize an Instant from an f64

This comes from the following encountered use case:

  • Same date time is transmitted over the wire in a Modified Julian days (in f64)
  • A time is added to that number, and we'd like another Modified Julian date from it.

Hence, either the constructor is added solely to MJ, or is it added to Instant. I'm in favor of the latter as I imagine similar use cases will occur with other time systems than MJ.

Less verbose `Datetime::with_offset`

The clippy tool notes the following:

warning: this function has too many arguments (8/7)
   --> src/datetime.rs:303:5
    |
303 | /     pub fn with_offset(
304 | |         year: i32,
305 | |         month: u8,
306 | |         day: u8,
...   |
342 | |         })
343 | |     }
    | |_____^
    |
    = note: #[warn(too_many_arguments)] on by default
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.179/index.html#too_many_arguments

I am looking for idea (or even PRs) which simplify the signature of this function. I initially wanted to code something up similar to chrono's Datetime<Utc>::new but that didn't seem like a correct pattern.

Handle custom formatting of dates

Devs may want to format dates differently. As such, it would be useful to support custom formats. My initial guess is that using the same formatting as Python would be useful. It could also be of interest to allow for custom formatters.

maybe_from_gregorian drops nanos parameter

While Epoch::maybe_from_gregorian validates that the nanos parameter is valid (via is_gregorian_valid), it does not actually include it in the quantity of seconds used to create the resulting Epoch.

I suppose the simple fix would be:

diff --git a/src/epoch.rs b/src/epoch.rs
index 1623ce8..ae9870c 100644
--- a/src/epoch.rs
+++ b/src/epoch.rs
@@ -265,7 +265,8 @@ impl Epoch {
         seconds_wrt_1900 += TimeUnit::Day * (day - 1)
             + TimeUnit::Hour * hour
             + TimeUnit::Minute * minute
-            + TimeUnit::Second * second;
+            + TimeUnit::Second * second
+            + TimeUnit::Nanosecond * nanos;
         if second == 60 {
             // Herein lies the whole ambiguity of leap seconds. Two different UTC dates exist at the
             // same number of second afters J1900.0.

Apologies if there's a reason for limiting this to second resolution that I didn't pick up on.

Convert crate to no-std

This will help us use it more easily on an embedded board without worry.

Quote from Matrix.org:

jplatte
xionbox: A good way to start is simply adding #![no_std] to your lib.rs and trying to convert all usages of std to the same things from core. You'll quickly notice whether there's stuff only in std that you depend on directly
Then you have to check all your dependencies to see whether they're all no_std or can be configured as such (often this is simply default-features = false)
There's little more to know beyond that AFAIK
https://github.com/core-error/core-error might be interesting if your library has its own error type(s)

Another potentially useful resource: https://github.com/johnthagen/min-sized-rust

Add and re-export useful constants

Re-exports should be a module level to make them easily available (unless specific to the module).

  • Number of seconds in a tropical year
  • Number of seconds per day should be moved from julian to root.
  • [ ]

Gregorian to/from in TAI incorrect

let dt = Epoch::from_gregorian_tai_at_midnight(2020, 1, 31);
println!("{}", dt.as_gregorian_utc_tai())

Prints
2020-01-30T23:59:23 TAI

Same with as_gregorian_utc_str

Initial implementation

  • Embedded leap seconds for time differences
  • Based on NTP at UTC but with a f64 seconds and a u64 fractions of seconds.
  • Time systems must provide a string representation and a time offset. The offset is of type std::Duration and an enum of AoT (Arrow of time) which is either Future or Past. This offset is computed with respect to UTC (NTP) only, but may easily support time dilation by reading the value of the current time on which it is computed. Should the signature be something like hifitime::MyTimeSystem::Offset() -> hifitime::Offset and the Offset struct defined as described above?
  • Time systems must provide a constructor such as hifitime::ModifiedJulian::from<f64>(245...) -> hifitime::Instant
  • Overload the operator + and its assignment counterpart for hifitime::Instant and hifitime::Offset such that an instant plus an offset returns another instant.
  • Overload the operator - and its assignment counterpart for two hifitime::Offsets to return another Offset.
  • Overload the operator - and its assignment counterpart for two hifitime::Instants to return an Offset.

Delegate TimeZones to chrono via cfg; support relativistic time correction

Currently, TimeZones aren't trivial to handle, as evident in tests/tz.rs. Even making an impl macro, as demonstrated here is not easy from that implementation.

It should be easy to convert a Utc to any other time zone object.

I guess that there needs to be some "generic date time container struct" which would house to computed date time with the computed offset, allowing for easy back and forth computations. Moreover, I don't think it's a great idea to require each TimeZone implementation to also implement fmt::Display : they will all be very similar so there needs to be a simple way to do this...

Allow to add and subtract durations from `Utc`

This should return another Utc. This will be needed to support loops over time, such as:

let mut current = Utc::new(/*...*/);
let end =  Utc::new(/*...*/);
while current < end {
/* do stuff */
    current += std::time::Duration(1, 0) // Or current += 1*SECOND
}

Eventually also include in this PR some short cuts such as:

hifitime::constants::{DAY, HOUR, MINUTE, SECOND, MICROSECOND, NANOSECOND};

Note that these short cut will need to support multiplications with floats and unsigned integers to make it useful. This may require some custom implementation such as hifitime::StdDuration::from_hours() or hifitime::StdDuration::from_seconds(10). I am pretty sure I cannot just use hifitime::Duration since it's re-exported.

Changes for nyx

As I'm porting Nyx to hifitime 2, there are additional changes which will greatly simplify the clarity of the code.

Convert back to Gregorian UTC

The function should be as_gregorian_utc. I do not think there should be a as_gregorian_tai because that's confusing: no one needs a TAI date if it's in Gregorian...

Support adding seconds to a current time

Currently, to add seconds to an existing Epoch, one must do the following:

let mut end_time = start_time;
end_time.mut_add_secs(prop_time);

That's just annoying. I have use for, where prop_time would be an f64.

let end_time = start_time + prop_time

Add a way to truncate dates?

This could be useful as a shortcut to handle dates only instead of always handling date times. My initial guess is that this can be written as a separate TimeSystem, but I'm not sure yet.

Add more TAI/UTC tests

There is currently a conversion error between TAI and UTC. In the current implementation TAI is behind UTC by 37 seconds, when in fact it should be ahead of it: http://leapsecond.com/java/gpsclock.htm .

    let now_tai = Epoch::from_gregorian_tai(2019, 8, 1, 20, 0, 0, 0);
    let now_utc = Epoch::from_gregorian_tai(2019, 8, 1, 20, 0, 0, 0);
    println!("{}", now_tai.as_tai_seconds() - now_utc.as_tai_seconds());

Returns: -37
Returns: 0 because (same function call)

Provide `FixedOffset` general timezones

Based on the KiloTZ test, it should be possible to provide a simple fixed offset time zone. Global time zones are only set by quarter hour at most, so maybe use a naming convention similar to chrono?

let ex1 = FixedOffset::east::from_hours(5).and_mins(15);
let ex2 = FixedOffset::east::from_mins(5);
let ex3 = FixedOffset::west::from_secs(5);

I need to think about this because I'm not a huge fan of chrono's naming convention in the first place.

ModifiedJulian should specify the reference

There is UT1, UTC, TAI, GPS Time julian days. It should be clear that the current version is the UTC. TAI and GPS should also be supported (these are the same as UTC with less or no leap seconds and some extra offset for TAI).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.