Golang的time.Unix()函数可能存在的一个BUG
2014-04-09 00:00
381 查看
摘要: 在调用time.Unix()时,我本来是想确定math.MaxInt64,最大能表示的日期是多少,最后发现转换出来的字符串日期不是完全正确,请看代码的执行结果。问题可能出在time转换部分,或出现在字符串装换部分,总之这应该是一个BUG。
执行结果如下:
fmt.Printf("math.MaxInt64 to time.Unix=[%s]\n", time.Unix(math.MaxInt64, 0)) fmt.Printf("math.MaxInt64/10 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/10, 0)) fmt.Printf("math.MaxInt64/100 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/100, 0)) fmt.Printf("math.MaxInt64/1000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/1000, 0)) fmt.Printf("math.MaxInt64/10000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/10000, 0)) fmt.Printf("math.MaxInt64/100000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/100000, 0)) fmt.Printf("math.MaxInt64/1000000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/1000000, 0)) fmt.Printf("math.MaxInt64/10000000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/10000000, 0)) fmt.Printf("math.MaxInt64/100000000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/100000000, 0)) fmt.Printf("math.MaxInt64/1000000000 to time.Unix=[%s]\n", time.Unix(math.MaxInt64/1000000000, 0))
执行结果如下:
math.MaxInt64 to time.Unix=[219250468-12-04 23:30:07 +0800 CST]math.MaxInt64/10 to time.Unix=[-837066640-09-10 09:33:00 +0800 CST]math.MaxInt64/100 to time.Unix=[-1372195080-04-09 08:09:18 +0800 CST]math.MaxInt64/1000 to time.Unix=[292278994-08-17 15:12:55 +0800 CST]math.MaxInt64/10000 to time.Unix=[29229672-06-18 01:31:17 +0800 CST]math.MaxInt64/100000 to time.Unix=[2924740-04-01 00:09:07 +0800 CST]math.MaxInt64/1000000 to time.Unix=[294247-01-10 12:00:54 +0800 CST]math.MaxInt64/10000000 to time.Unix=[31197-09-14 10:48:05 +0800 CST]math.MaxInt64/100000000 to time.Unix=[4892-10-08 05:52:48 +0800 CST]math.MaxInt64/1000000000 to time.Unix=[2262-04-12 07:47:16 +0800 CST] |
相关文章推荐
- 一个可能存在Bug的二分查找方法的实现,大家一起看看有什么问题没
- VCLSkin可能存在的一个bug隐患
- PHP7 realpath函数一个长期存在的bug
- VS、GNU STL存在一个Bug,而STLport-5.2.1则是没有的。已经过侯捷先生确认!!
- FROM_UNIXTIME 格式化MYSQL时间戳函数
- mysql 时间戳格式化函数from_unixtime使用说明
- 生成一个一维数组,有10个元素,都用随机数填充,用指针轮询的办法实现函数查找一个数是否存在。
- MySQL的FROM_UNIXTIME()和UNIX_TIMESTAMP()函数的区别
- EJS前端版的一个小问题,可能是bug.
- 一个winXP下通过远程连接的方式拷贝信息存在的BUG
- mysql中UNIX_TIMESTAMP()函数和php中time()函数的区别
- FROM_UNIXTIME 格式化MYSQL时间戳函数
- MySQL的FROM_UNIXTIME()和UNIX_TIMESTAMP()函数的区别
- 一个页面使用两次timepicker.js引起的Maximum call stack size exceeded问题解决办法及bug修复
- mysql 5.6 时间函数的变化 FROM_UNIXTIME CURRENT_TIMESTAMP
- Golang记录、计算函数执行耗时、运行时间的一个简单方法
- PHP - Manual手册 - XXII. Date/Time 日期/时间函数 - date格式化一个本地时间/日期
- MySQL的FROM_UNIXTIME()和UNIX_TIMESTAMP()函数的区别
- 实现一个最简单的VIM文本编辑器(可能有bug,随便写了一个)
- 如果一个函数中有局部对象的存在, 那么它就一定会存在 C++ 的异常处理机制