45 lines
1.3 KiB
Solidity
45 lines
1.3 KiB
Solidity
|
pragma solidity ^0.4.24;
|
||
|
|
||
|
import "./Uint256Helpers.sol";
|
||
|
|
||
|
|
||
|
contract TimeHelpers {
|
||
|
using Uint256Helpers for uint256;
|
||
|
|
||
|
/**
|
||
|
* @dev Returns the current block number.
|
||
|
* Using a function rather than `block.number` allows us to easily mock the block number in
|
||
|
* tests.
|
||
|
*/
|
||
|
function getBlockNumber() internal view returns (uint256) {
|
||
|
return block.number;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dev Returns the current block number, converted to uint64.
|
||
|
* Using a function rather than `block.number` allows us to easily mock the block number in
|
||
|
* tests.
|
||
|
*/
|
||
|
function getBlockNumber64() internal view returns (uint64) {
|
||
|
return getBlockNumber().toUint64();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dev Returns the current timestamp.
|
||
|
* Using a function rather than `block.timestamp` allows us to easily mock it in
|
||
|
* tests.
|
||
|
*/
|
||
|
function getTimestamp() internal view returns (uint256) {
|
||
|
return block.timestamp; // solium-disable-line security/no-block-members
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dev Returns the current timestamp, converted to uint64.
|
||
|
* Using a function rather than `block.timestamp` allows us to easily mock it in
|
||
|
* tests.
|
||
|
*/
|
||
|
function getTimestamp64() internal view returns (uint64) {
|
||
|
return getTimestamp().toUint64();
|
||
|
}
|
||
|
}
|