当前位置:网站首页>Time format conversion
Time format conversion
2022-07-05 04:56:00 【Meteor spot】
-- Convert time seconds to 2018-10-1 10:10:20 Format
local function timestamp(ct)
local t = os.date("*t",ct)
return string.format("%04d-%02d-%02d %02d:%02d:%02d", t.year, t.month, t.day, t.hour, t.min, t.sec)
end
-- Convert numbers into uppercase Chinese characters for display
function App.toChineseCapital(num)
local cnum = {" zero ", " one ", " Ii. ", " 3 ", " boss ", " wu ", " lu ", " Retailer, ", " ", " nine "}
local cunit = {" Ten ", " Bai ", " Thousand ", " ten thousand ", " Ten ", " Bai ", " Thousand ", " Billion "}
num = math.floor(num)
local result = ""
local zero = true
local count = 0
local whole = ""
while num > 0 do
local n = num % 10 + 1
if n == 1 then
if count > 0 and count % 4 == 0 then
if count % 8 == 0 then
whole = cunit[8]
else
whole = cunit[4]
end
end
if not zero and count % 4 ~= 0 then
result = cnum[n] .. result
end
zero = true
else
local c = count % 8
if count > 0 and c == 0 then
c = 8
end
if c == 4 or c == 8 then
whole = ""
end
local unit = cunit[c] or ""
result = string.format("%s%s%s%s", cnum[n], unit, whole, result)
zero = false
whole = ""
end
count = count + 1
num = math.floor(num / 10)
end
return result
end
边栏推荐
- AutoCAD - scaling
- C # perspective following
- Is $20billion a little less? Cisco is interested in Splunk?
- C iterator
- UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
- AutoCAD - workspace settings
- 中国溶聚丁苯橡胶(SSBR)行业研究与预测报告(2022版)
- Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
- The first topic of ape Anthropology
- 中国艾草行业研究与投资前景预测报告(2022版)
猜你喜欢
Looking at Chinese science and technology from the Winter Olympics: what is the mystery of the high-speed camera that the whole people thank?
Pdf to DWG in CAD
SQL set operation
2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
Minor spanning tree
質量體系建設之路的分分合合
Solution of circular dependency
xss注入
Rip notes [rip message security authentication, increase of rip interface measurement]
随机推荐
Understand encodefloatrgba and decodefloatrgba
The difference between bundle, chunk and module
Error statuslogger log4j2 could not find a logging implementation
On-off and on-off of quality system construction
AutoCAD - graphic input and output
Inline built-in function
質量體系建設之路的分分合合
MD5 bypass
AutoCAD - stretching
【acwing】836. Merge sets
UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
Variable category (automatic, static, register, external)
AutoCAD - full screen display
Function overloading
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
Emlog blog theme template source code simple good-looking responsive
AutoCAD - workspace settings
Introduce Hamming distance and calculation examples
Create a pyGame window with a blue background
2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling