4

I have tried to add the latest version of chrono but seems to fail throwing multiple errors.

  • Anchor version: anchor-cli 0.25.0
  • Rust version: rustc 1.63.0 (4b91a6ea7 2022-08-08)
  • Chrono version: 0.4.22
  • Rustup toolchain (using mac with chip M1):
    stable-aarch64-apple-darwin (default)
    

Error log when executing anchor build:

error[E0432]: unresolved import `self::inner`
 --> src/sys.rs:3:15
  |
3 | pub use self::inner::*;
  |               ^^^^^ could not find `inner` in `self`

error[E0433]: failed to resolve: could not find `SteadyTime` in `sys`
   --> src/lib.rs:251:25
    |
251 |         SteadyTime(sys::SteadyTime::now())
    |                         ^^^^^^^^^^ could not find `SteadyTime` in `sys`

error[E0425]: cannot find function `get_time` in module `sys`
   --> src/lib.rs:153:28
    |
153 |     let (sec, nsec) = sys::get_time();
    |                            ^^^^^^^^ not found in `sys`

error[E0425]: cannot find function `get_precise_ns` in module `sys`
   --> src/lib.rs:164:10
    |
164 |     sys::get_precise_ns()
    |          ^^^^^^^^^^^^^^ not found in `sys`

error[E0412]: cannot find type `SteadyTime` in module `sys`
   --> src/lib.rs:246:28
    |
246 | pub struct SteadyTime(sys::SteadyTime);
    |                            ^^^^^^^^^^ not found in `sys`

error[E0425]: cannot find function `time_to_utc_tm` in module `sys`
   --> src/lib.rs:408:10
    |
408 |     sys::time_to_utc_tm(sec, &mut tm);
    |          ^^^^^^^^^^^^^^ not found in `sys`

error[E0425]: cannot find function `time_to_local_tm` in module `sys`
   --> src/lib.rs:422:10
    |
422 |     sys::time_to_local_tm(sec, &mut tm);
    |          ^^^^^^^^^^^^^^^^ not found in `sys`

error[E0425]: cannot find function `utc_tm_to_time` in module `sys`
   --> src/lib.rs:436:23
    |
436 |             0 => sys::utc_tm_to_time(self),
    |                       ^^^^^^^^^^^^^^ not found in `sys`

error[E0425]: cannot find function `local_tm_to_time` in module `sys`
   --> src/lib.rs:437:23
    |
437 |             _ => sys::local_tm_to_time(self)
    |                       ^^^^^^^^^^^^^^^^ not found in `sys`

1 Answer 1

0

Seems like there are two ways of retrieving Clock according Solana docs:

  1. Passing SYSVAR_CLOCK_PUBKEY into an instruction

    let clock = Clock::from_account_info(&sysvar_clock_pubkey)?;
    let current_timestamp = clock.unix_timestamp;
    
  2. Accessing Clock directly inside an instruction.

    let clock = Clock::get()?;
    let current_timestamp = clock.unix_timestamp;
    

Looks like we shouldn't use external libs for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.