-1

I want to use the icu_date library, but when I try to insert a value, an error appears

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)'

Maybe there are not enough libraries?

  • Library libicu-devel-50.2-4.el7_7.x86_64
  • System: Centos 7
Alexander Mashin
  • 3,892
  • 1
  • 9
  • 15
denisT
  • 1
  • 2

1 Answers1

0

Seems you need to use icu_date.new() (not now) to create new instance. Then you can use it in the way you want:

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() returns current time. That's actually a number value.

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

tarantool> icu_date.now()
---
- 1602597687320
...
Oleg Babin
  • 409
  • 3
  • 9
  • Oleg, I do as you wrote, an error appears: .rocks/share/tarantool/icu-date/init.lua:17: tarantool init.lua: undefined symbol: udat_formatCalendar_50' – denisT Oct 14 '20 at 03:37
  • Seems you use too old version of icu-date. I suggest you to update libicu and file an issue (https://github.com/tarantool/icu-date/issues), I think it's possible to fix compatibility with older versions. – Oleg Babin Oct 14 '20 at 08:06