Need help with ethereum-datetime?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

pipermerriam
286 Stars 105 Forks MIT License 23 Commits 10 Opened issues

Description

Date-Time utilities for ethereum contracts.

Services available

!
?

Need anything else?

Contributors list

# 42,067
python-...
solidit...
Shell
ethereu...
12 commits
# 249,585
Python
Go
2 commits
# 226,339
JavaScr...
solidit...
marketp...
Xcode
1 commit
# 480,971
JavaScr...
Shell
CSS
bootcam...
1 commit
# 496,114
Python
Clojure
1 commit
# 55,124
Shell
solidit...
zeppeli...
evm
1 commit

Ethereum Date and Time tools

Contract which implements utilities for working with datetime values in ethereum.

Contract Deployments:

To verify, you need to compare the code on the blockchain with the runtime code which can be gotten from

solc contracts/DateTime.sol --optimize --bin-runtime
.

Also you can find it already verified at https://etherscan.io/address/0x1a6184cd4c5bea62b0116de7962ee7315b7bcbce#code

DateTime struct

Internally, the following struct is used to represent date-time object.

struct DateTime {
        uint16 year;
        uint8 month;
        uint8 day;
        uint8 hour;
        uint8 minute;
        uint8 second;
        uint8 weekday;
}

API

  • isLeapYear(uint16 year) constant returns (bool)

Given an integer year value, returns whether it is a leap year.

  • parseTimestamp(uint timestamp) internal returns (DateTime dt)

Given a unix timestamp, returns the

DateTime
representation of it.
  • getYear(uint timestamp) constant returns (uint16)

Given a unix timestamp, returns the

DateTime.year
value for the timestamp.
  • getMonth(uint timestamp) constant returns (uint16)

Given a unix timestamp, returns the

DateTime.month
value for the timestamp.
  • getDay(uint timestamp) constant returns (uint16)

Given a unix timestamp, returns the

DateTime.day
value for the timestamp.
  • getHour(uint timestamp) constant returns (uint16)

Given a unix timestamp, returns the

DateTime.hour
value for the timestamp.
  • getMinute(uint timestamp) constant returns (uint16)

Given a unix timestamp, returns the

DateTime.minute
value for the timestamp.
  • getSecond(uint timestamp) constant returns (uint16)

Given a unix timestamp, returns the

DateTime.second
value for the timestamp.
  • getWeekday(uint timestamp) constant returns (uint8)

Given a unix timestamp, returns the

DateTime.weekday
value for the timestamp.
  • toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) constant returns (uint timestamp)
  • toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) constant returns (uint timestamp)
  • toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) constant returns (uint timestamp)
  • toTimestamp(uint16 year, uint8 month, uint8 day) constant returns (uint timestamp)

Returns the unix timestamp representation for the given date and time values.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.