icu_date gives an error message attempt to index a number value

124 Views Asked by At

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
1

There are 1 best solutions below

2
On BEST ANSWER

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
...