-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstat-utils.sk
More file actions
61 lines (49 loc) ยท 2.13 KB
/
stat-utils.sk
File metadata and controls
61 lines (49 loc) ยท 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#์ต์
์ ์ค์ ๋ ํ๋ฅ ์ ๊ณ์ฐ์์ ์ฌ์ฉํ ํ๋ฅ ๋ก ๋ณํ
function rpp_ConvertRate(rate:number) :: number:
return {_rate} / 10000
#์ต์
์ ์ค์ ๋ ํ๋ฅ ์ %ํ๋ฅ ๋ก ๋ณํ
function rpp_ConvertRateToPercent(rate:number) :: number:
return {_rate} / 100
function rpp_ConvertCalRateToPercent(rate:number) :: number:
return {_rate} * 100
function rpp_ReconverionRate(rate:number) :: number:
return {_rate} * 10000
#๊ณ์ฐ์์ ์ฌ์ฉํ ํ๋ฅ ์ %ํ๋ฅ ๋ก ๋ฐํ
#Date ์ ๋ณด๋ฅผ ์ฝ์ ์ ์๋๋ก ๋ณํ
function rpp_TimeFormatted(d:date) :: string:
return {_d} formatted human-readable
#Timespan ์ ๋ณด๋ฅผ ์ด ๋จ์๋ก ๋ฐํ
function rpp_TimeFormattedToSeconds(t:timespan) :: number:
set {_time} to "%{_t}%"
replace " ", "and", "second" and "seconds" with "" in {_time}
replace "days", "hours", "day", "hour", "minute" and "minutes" with ":" in {_time}
set {_time::*} to {_time} split by ":"
set {_r::*} to rpp_Reversed({_time::*})
add round {_r::1} parsed as number to {_seconds}
add round {_r::2} parsed as number * 60 to {_seconds}
add round {_r::3} parsed as number * 3600 to {_seconds}
add round {_r::4} parsed as number * 86400 to {_seconds}
return {_seconds}
#๋ฐฐ์ด์ ์ญ์์ผ๋ก ์ ๋ ฌ
function rpp_Reversed(o::*:objects) :: objects:
set {_copy::*} to {_o::*}
loop {_o::*}:
set {_reversed::%loop-index%} to last element of {_copy::*}
remove {_reversed::%loop-index%} from {_copy::*}
return {_reversed::*}
#์ซ์๋ฅผ ์
๋ ฅํ ์๋ฆฟ์์ ๋ง์ถฐ ์ซ์ ์์ 0์ ์ถ๊ฐ์์ผ ๋ฌธ์์ด๋ก ๋ฐํ, ์ซ์์ ํฌ๊ธฐ๊ฐ ์๋ฆฟ์๋ณด๋ค ํฌ๋ค๋ฉด 999999 ์ ๊ฐ์ด ๋ฐํ, ๋น์นธ, ์ค์ ์ซ์๋ฅผ ํ๊ธฐํ ์ ์ถ๊ฐ
function rpp_NumberFormat(num:number, format:integer, blank:string, color:string) :: string:
set {_n} to "%{_num}%"
set {_n::*} to {_n} split by ""
set {_size} to size of {_n::*} - 1
set {_text} to ""
if {_size} > {_format}:
loop {_format} times:
set {_text} to "%{_text}%%{_color}%9"
return {_text}
set {_loop} to {_format} - {_size}
loop {_loop} times:
set {_text} to "%{_text}%%{_blank}%0"
loop {_n::*}:
set {_text} to "%{_text}%%{_color}%%loop-value%"
return {_text}