codecamp

System

System 库

System库为使用者提供了一些较为便捷或一些作者自行实现的一些库的封装.

System库的API具体使用方法与后续产生的变更请在此进行查阅.

System库的导入方式为: local system = require "system"

system.now()

返回微秒级的时间戳(float)

system.is_ip(string)

判断字符串是否合法IP地址格式.
IPv4返回true, 4; IPv6返回true, 6.

system.is_ipv4(string)

判断字符串是否合法IPv4格式. 返回值为boolean.

system.is_ipv6(string)

判断字符串是否合法IPv6格式. 返回值为boolean.

system.is_int(number)

判断number是否int类型. 返回值为boolean.(如果number & math.maxinteger或者小于 math.maxinteger可能始终返回true)

system.is_float(number)

判断number是否float类型. 返回值为boolean.(如果number & math.maxinteger或者小于 math.maxinteger可能始终返回true)

system.is_string(string, empty)

判断string是否合法字符串类型. 返回值为boolean. 如果empty = true, 则增加判断string == ''.(空字符串有时候没意义)

system.is_array_member(array, value)

判断value是否为array成员, 返回值为boolean. (array不可为稀疏数组)

system.is_table_member(table, value)

判断value是否为table成员, 返回值为boolean.

system.same_day(timestamp)

返回值为timestamp当日的临晨时间(00:00:00)与午夜时间23:59:59, 没有timestamp等同于传入os.time()

cf
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

API 使用手册

HTTP API

Mail API

DB API

DB

Cache API

class API

MQ API

MQ

Crypt API

cf API

cf

System API

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }