Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get current_time/now in C++ in 1.6 #470

Closed
MrToph opened this issue Mar 23, 2019 · 2 comments
Closed

How to get current_time/now in C++ in 1.6 #470

MrToph opened this issue Mar 23, 2019 · 2 comments

Comments

@MrToph
Copy link

@MrToph MrToph commented Mar 23, 2019

As system.h header will be removed when using C++ in v1.7, I'd like to use an alternative to now() and current_time() that is in a .hpp header.

Even when importing system.hpp now, it cannot find these functions:

#include <eosio/system.hpp>
error: use of undeclared identifier 'now'; did you mean 'new'?
@duyluong1994

This comment has been minimized.

Copy link

@duyluong1994 duyluong1994 commented Mar 23, 2019

From eosio.cdt v1.6 onwards
You have to #include <eosio/system.hpp> and then you can use:

eosio::current_time_point
eosio::current_block_time
to cast from time_point to uint32_t u can use like:
eosio::current_time_point().sec_since_epoch();

@godmar

This comment has been minimized.

Copy link

@godmar godmar commented Nov 20, 2019

It is unclear what returning uint32_t means. Is the expectation that EOS will have been phased out by the year 2038? Or does sec_since_epoch return a mod 2^32 of the actual time? If so, it seems an error prone API to include.

I checked the documentation already, but it didn't clarify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.