new Utility()
This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
phone, etc.
- Source:
Methods
formatNumber(number, point) → {String}
格式化數字補千分位,固定小數n位
formatNumber(1234.123, 2)
Parameters:
| Name | Type | Description |
|---|---|---|
number |
String | 傳入值 |
point |
String | 固定小數n位 |
- Source:
Returns:
num 1,234.12
- Type
- String
getCurrentDate() → {String}
取得當下民國日期
- Source:
Returns:
109年01月02日
- Type
- String
getCurrentDateDiff(diff) → {String}
取得當下日期減天數
getCurrentDateDiff(2) 假設當下是2020/01/03
Parameters:
| Name | Type | Description |
|---|---|---|
diff |
String | 欲減掉的天數 |
- Source:
Returns:
傳回就是2020/01/01
- Type
- String
getCurrentTime() → {String}
取得當下時間(時跟分)
- Source:
Returns:
18時10分
- Type
- String
getInfo(successCallback, errorCallback)
取得行動裝置資訊
Parameters:
| Name | Type | Description |
|---|---|---|
successCallback |
function | The function to call when the heading data is available |
errorCallback |
function | The function to call when there is an error getting the heading data. (OPTIONAL) |
- Source:
getLastMonthCurrentDate(num) → {String}
取得N個月前的當天
假設當天是109/01/02
Parameters:
| Name | Type | Description |
|---|---|---|
num |
String | 往前n個月 |
- Source:
Returns:
回傳108/12/02
- Type
- String
getNextMonthCurrentDate(num) → {String}
取得N個月後的當天
假設當天是109/01/02
Parameters:
| Name | Type | Description |
|---|---|---|
num |
String | 往後n個月 |
- Source:
Returns:
回傳109/02/02
- Type
- String
getParameterByName(name, num) → {String}
取得網址參數的值
假設網址(url)是https://a.b.c/xxx.aspx?x=val1&y=val2, getParameterByName(y,url)
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | 欲取得的參數名稱 |
num |
String | 完整的網址 |
- Source:
Returns:
回傳y的值是val2
- Type
- String
leftPad(value, length) → {String}
固定n位數, 不足補0
leftPad(1,3)
Parameters:
| Name | Type | Description |
|---|---|---|
value |
int | 傳入值 |
length |
int | n位數 |
- Source:
Returns:
str 001
- Type
- String
twd97_to_latlng($x, $y) → {array}
TWD97轉WGS84
Parameters:
| Name | Type | Description |
|---|---|---|
$x |
float | TWD97 x坐標 |
$y |
float | TWD97 y坐標 |
- Source:
Returns:
回傳WGS84坐標陣列
- Type
- array
yyy2yyyy() → {String}
民國年轉西元年
yyyy2yyy('107年01月02日')
- Source:
Returns:
2020年01月02日
- Type
- String
yyyy2yyy() → {String}
西元年轉民國年
yyyy2yyy('2020年01月02日')
- Source:
Returns:
109年01月02日
- Type
- String