【问题标题】:icu_date gives an error message attempt to index a number valueicu_date 给出错误消息尝试索引数字值
【发布时间】:2020-10-14 11:42:08
【问题描述】:

我想使用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

【问题讨论】:

    标签: lua tarantool tarantool-cartridge


    【解决方案1】:

    似乎您需要使用icu_date.new()(而不是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
    ...
    

    【讨论】:

    • 奥列格,我照你说的做,出现错误:.rocks/share/tarantool/icu-date/init.lua:17: tarantool init.lua: undefined symbol: udat_formatCalendar_50'
    • 看来您使用的 icu-date 版本太旧了。我建议你更新 libicu 并提交问题(github.com/tarantool/icu-date/issues),我认为可以修复与旧版本的兼容性。
    猜你喜欢
    • 2014-03-26
    • 2017-07-23
    • 1970-01-01
    • 2013-08-29
    • 2014-06-29
    • 1970-01-01
    • 2010-12-21
    • 2020-04-22
    • 1970-01-01
    相关资源
    最近更新 更多