情景1:现在有一个道具商店,共有10个道具可购买。玩家可使用某道具或钻石刷新道具商店中的道具,或者系统会每隔2小时赠送一次刷新次数。

问题1:如何实现间隔2小时实时刷新?

from datetime import datetime

def cal_count(timestamp):
    now_dt  = datetime.now()
    base_dt = datetime.fromtimestamp(0)
    last_dt   = datetime.fromtimestamp(timestamp)
 
    count = ((now_dt.date() - base_dt.date()).days*12 + now_dt.hour/2) - \
            ((last_dt.date() - base_dt.date()).days*12 + last_dt.hour/2)

    return count

if __name__ == "__main__":
    last_ts = 1433000132
    print cal_count(last_ts)
View Code

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2021-12-11
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-10-18
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2022-01-13
  • 2021-11-26
  • 2022-12-23
相关资源
相似解决方案