Swiftzn wrote:Ho K
I think you don't need the lua function you tried to use. That function converts the Unix epoch timestamps into Windows timestamps, which is not exactly what you need. I think instead you'd like to convert the timestamp returned by the [MeasureTXOneTime] WebParser measure of your code to usual date and time (like 12/15/2017 7:00:00 - this is just an example, has nothing to do with the value returned for example right now). Am I right?
If I am, here is the solution: first you've disabled the [MeasureConvertTime] script measure of your code (with a
Disabled=1 option). Forget it and remove this
Disabled=1 option. Otherwise you have to enable the measure, when it should make the conversion.
Secondly, you've added to the lua code just the ConvertTime function, nothing else. This way the lua code won't interact with the skin where it is used. You have two way to make this happening: through the Initialize() (which is executed just once, when the skin is loaded or refreshed), respectively through the Update() (executed on each update cycle of the skin) functions.
Here is the rewritten lua code. Please replace your old code with this one:
Code: Select all
function Update()
TXOneTime = SKIN:GetMeasure('MeasureTXOneTime')
TXOneTimeNum = TXOneTime:GetValue()
local Year, Month, Day, Hour, Minute, Second = os.date("%Y", TXOneTimeNum), os.date("%m", TXOneTimeNum), os.date("%d", TXOneTimeNum), os.date("%H", TXOneTimeNum), os.date("%M", TXOneTimeNum), os.date("%S", TXOneTimeNum)
return Month..'/'..Day..'/'..Year..' '..Hour..':'..Minute..':'..Second
end
--function ConvertTime(n, To)
-- local Formats = {
-- Unix = -1
-- Windows = 1
-- }
-- return Formats[To] and n + 11644473600 * Formats[To] or nil
--end
See I left there the ConvertTime function, but it is commented out, so won't be used (but don't even need it any more).
The first two lines of the Update() function get the value returned by the [MeasureTXOneTime] (first line) and convert it to numeric format (second line). In the third line I introduced six variable, which will keep the year, month, day, hour, minute and second of the timestamp, accordingly. The last line returns these value through the Month/Day/Year Hour:Minute:Second format. You can modify this format, if you need it in any other form (and I suppose you'll need to modify it). See
here how can you change the format of the returned variable.
Now the last step would be to use the returned value into your skin. If you did all the above modification to both the code of the skin and to the lua code, the [MeasureConvertTime] Script measure returns the date in the mentioned form. You'll have to use its value: add the
MeasureName=MeasureConvertTime option to the [MeterTXOneTime] meter and replace its Text option with
Text=%1.
I think here is one more problem: it seems the above string is going outside of the skin (to right). Reduce the X value of it. Eg try with
X=20.
Please let me know if this is what you needed.