Verified contractPartial
DateTime
Address0x6e8f3d445d9aaeb6d2e8f43b6bbd44eb6a7fd83e
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.4.18
- Same code
9 more contracts
Details
- Compiler
- solc 0.4.18+commit.9cf6e910
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 6,163,317
- Creation transaction
- 0xf109dec125…756818661c
a965A26c00371D32Fef402CB1E7F268E61710e15_ApcrdaZebichain.sol
// Recovered by EthereumHistory (ethereumhistory.com) -sw
pragma solidity ^0.4.18;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract DateTime {
struct _DateTime {
uint16 year;
uint8 month;
uint8 day;
}
uint constant DAY_IN_SECONDS = 86400;
uint constant YEAR_IN_SECONDS = 31536000;
uint constant LEAP_YEAR_IN_SECONDS = 31622400;
uint16 constant ORIGIN_YEAR = 1970;
uint constant GMT_TO_LOCAL = 19800;
function toTimestamp(uint16 year, uint8 month, uint8 day) public returns (uint timestamp) {
uint16 i;
// Year
for (i = ORIGIN_YEAR; i < year; i++) {
if (isLeapYear(i)) {
timestamp += LEAP_YEAR_IN_SECONDS;
}
else {
timestamp += YEAR_IN_SECONDS;
}
}
// Month
uint8[12] memory monthDayCounts;
monthDayCounts[0] = 31;
if (isLeapYear(year)) {
monthDayCounts[1] = 29;
}
else {
monthDayCounts[1] = 28;
}
monthDayCounts[2] = 31;
monthDayCounts[3] = 30;
monthDayCounts[4] = 31;
monthDayCounts[5] = 30;
monthDayCounts[6] = 31;
monthDayCounts[7] = 31;
monthDayCounts[8] = 30;
monthDayCounts[9] = 31;
monthDayCounts[10] = 30;
monthDayCounts[11] = 31;
for (i = 1; i < month; i++) {
timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1];
}
// Day
timestamp += DAY_IN_SECONDS * (day - 1);
timestamp-=GMT_TO_LOCAL;
return timestamp;
}
function isLeapYear(uint16 year) public pure returns (bool) {
if (year % 4 != 0) {
return false;
}
if (year % 100 != 0) {
return true;
}
if (year % 400 != 0) {
return false;
}
return true;
}
}
contract ApcrdaZebichain is Ownable{
mapping (uint256 =>string ) event_details; // timestamp to hash
DateTime public dt;
function ApcrdaZebichain() public{
}
function viewMerkleHash(uint16 year, uint8 month, uint8 day) public view returns(string hash)
{
uint time = dt.toTimestamp(year,month,day);
hash= event_details[time];
}
function insertHash(uint16 year, uint8 month, uint8 day, string hash) onlyOwner public{
dt = new DateTime();
uint t = dt.toTimestamp(year,month,day);
event_details[t]=hash;
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.