BC 中的日历 ISO8601DateFormatter 年份范围

问题描述

我目前正在学习 Swift 中用于 IOS 开发的 ISO8601 实现。我目前只关心 BC 和 AD 中具有日期功能的 YEAR。在下面的代码中,我发现 ISO8601DateFormatter() 可以从字符串 year -5838268 中读取,即 5838269BC。这很酷。但是,当我将该日期读回字符串时,我丢失了负数,这迫使我使用 dateComponent 通过另一个语句计算 ERA。而不是 -5838268。

如果我继续使用 dateComponent,我确实会为“-”获得 Era,但 Year 仅限于 4713,即 4714BC。

有没有一种方法可以让我读取 ISO8601 中的 Date 结构,而不是通过 dateComponent 过程来保留“-”号。或者使用 dateComponent 完全读取 -5838268?我想做任何一个。目前,我只能考虑解析该日期字符串以提取年份并执行 dateComponent 以获取 ERA 并分配 - 用于 BC。只是听起来不干净。

contract Token {

  mapping(address => uint) balances;
  uint public totalSupply;
  uint public anotherUint = 10;

  constructor(uint _initialSupply,uint _anotherUint) {
    balances[msg.sender] = totalSupply = anotherUint = _initialSupply = _anotherUint;
  }

  function transfer(address _to,uint _value) public returns (bool) {
    require(balances[msg.sender] - _value >= 0);
    balances[msg.sender] -= _value;
    balances[_to] += _value;
    return true;
  }

  function balanceOf(address _owner) public view returns (uint balance) {
    return balances[_owner];
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)