标签:
function Split(szFullString, szSeparator) local nFindStartIndex = 1 local nSplitIndex = 1 local nSplitArray = {} while true do local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex) if not nFindLastIndex then nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString)) break end nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1) nFindStartIndex = nFindLastIndex + string.len(szSeparator) nSplitIndex = nSplitIndex + 1 end return nSplitArray --ceshi local currenttime = os.date(); --"04/23/2015 16:50:46" ;--= os.date(); print(os.date()); local cur_list = Split(currenttime," "); local cur_date_str = string.format("%s",cur_list[1]); local cur_time_str = string.format("%s",cur_list[2]); local cur_time_list = Split(cur_time_str,":"); local cur_data_list = Split(cur_date_str,"/"); print(cur_date_str) print(cur_time_str) for i = 1, #cur_data_list do str = string.format("index %d: value = %s", i, cur_data_list[i]); print(str); end for i = 1, #cur_time_list do str = string.format("index %d: value = %s", i, cur_time_list[i]); print(str); end
标签:
原文地址:http://blog.csdn.net/seanyxie/article/details/45315223