0

我想使用 icu_date 库,但是当我尝试插入一个值时,出现错误

icu_date = require("icu-date")
format_date = icu_date.formats.iso8601()
end_time = icu_date.now()
1602586287098 - print value
end_time:set_millis(1602461532000)
error: '[string "return end_time:set_millis(1602461532000)"]:1: attempt to index global ''end_time'' (a number value)'

也许没有足够的图书馆?

  • 库 libicu-devel-50.2-4.el7_7.x86_64
  • 系统:Centos 7
4

1 回答 1

0

似乎您需要使用icu_date.new()(not now) 来创建新实例。然后你可以按照你想要的方式使用它:

icu_date = require("icu-date")
format_date = icu_date.formats.iso8601()
end_time = icu_date.new()
end_time:set_millis(1602461532000)
tarantool> end_time:format(format_date)
---
- 2020-10-12T00:12:12.000Z
...

icu_date.now()返回当前时间。这实际上是一个数值。

tarantool> icu_date = require('icu-date')
---
...

tarantool> icu_date.now()
---
- 1602597687320
...
于 2020-10-13T14:04:22.847 回答