1 Star 0 Fork 0

zhupeng911/solidity

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
15-test_Time.sol 790 Bytes
一键复制 编辑 原始数据 按行查看 历史
朱鹏 提交于 2018-11-12 16:52 +08:00 . 时间类型
pragma solidity ^0.4.25;
import "./Datetime.sol";
//时间time
contract testTime{
//1、返回当前时间戳(某种计数法) now
function currTime() public constant returns(uint){
return block.timestamp;
//return now;
}
//2、一天最多使用一次
uint public lastTs;
function doSomething() public {
if(now - lastTs>=1 days){
//doSomething
}
lastTs=now;
}
//3、对时间库函数的一些操作
function getYear() public view returns(uint){
return DateTime.getYear(now);
}
function getMonth() public view returns(uint){
return DateTime.getMonth(now);
}
function getDay() public view returns(uint){
return DateTime.getDay(now);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhupeng911/solidity.git
git@gitee.com:zhupeng911/solidity.git
zhupeng911
solidity
solidity
master

搜索帮助