时间字符串及时间戳的同步生成 [脚本 ]
<script>{
:global timstring
:global unixstramp
:local timstr do={
:local Date ;
:local Year ([:pick $Date 7 11])
:local Month ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $Date 0 3]]);:set Month ($Month + 1);:if (1 = [:len $Month])do={:set Month "0$Month"}
:local Day [:pick $Date 4 6]
:local nn
:set nn (([:pick $nn 0 2]) . ( [:pick $nn 3 5]) . ( [:pick $nn 6 8]))
:return ("$Year$Month$Day$nn")
}
:set timstring [$timstr]
:local secs
:local days 0
:local year ([:tonum [:pick $timstring 0 4]])
:local month ([:tonum [:pick $timstring 4 6]])
:local day([:tonum [:pick $timstring 6 8]])
:local hh([:tonum [:pick $timstring 8 10]])
:local mm([:tonum [:pick $timstring 10 12]])
:local ss([:tonum [:pick $timstring 1214]])
:local daysarr [:toarray "31,28,31,30,31,30,31,31,30,31,30,31"]
:local unix2017 1483200000
:if ($month > 1) do={
:for i from=1 to=$month do={
:set days ($days+$daysarr->($i-1))
}
}
:if ($year>2017) do={
:for i from=2017 to=($year-1) do={
:set days ($days+1)
}
}
:set days ($days+$day-1)
:set secs($hh*3600+$mm*60+$ss)
:set secs ($secs + $days*3600*24 + $unix2017)
:set unixstramp $secs
:put ($timstring . "" .$unixstramp)
}
</script>
主要功能是同步当前时间日期成时间戳,有需要的用,没有需要的绕过。
页:
[1]