-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstat-utils.sk
61 lines (49 loc) · 2.13 KB
/
stat-utils.sk
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}