Forum

> > CS2D > Scripts > String to Epoch Returning nil.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch String to Epoch Returning nil.

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt String to Epoch Returning nil.

Mami Tomoe
User Off Offline

Zitieren
Hi, I'm experimenting with some time/date functions and I've come acoss this strange issue:

The code:
1
2
3
4
5
function string_to_epoch(str)
	local t_hour, t_min, t_sec, t_day, t_month, t_year = str:match('(%d+):(%d+):(%d+) (%d+)/(%d+)/(%d+)')
	
	return os.time({ year = t_year, month = t_month, day = t_day, hour = t_hour, min = t_min, sec = t_sec, isdst = false })
end

The input:
1
'05:34:01 23/06/19'

The output:
nil


I've checked and the table does seem to contain the information it's supposed to.

alt Re: String to Epoch Returning nil.

Baloon
GAME BANNED Off Offline

Zitieren
Try using
table.sort
?

1
return os.time(table.sort({ year = t_year, month = t_month, day = t_day, hour = t_hour, min = t_min, sec = t_sec, isdst = false }))
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht