GithubHelp home page GithubHelp logo

dulumao / ethereum-datetime Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pipermerriam/ethereum-datetime

0.0 0.0 0.0 30 KB

Date-Time utilities for ethereum contracts.

License: MIT License

Python 100.00%

ethereum-datetime's Introduction

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.

ethereum-datetime's People

Contributors

anrodon avatar craig-ludington avatar daveappleton avatar fakel avatar pipermerriam avatar wanderingstan avatar

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.