Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
6c31b386
Commit
6c31b386
authored
Nov 01, 2022
by
yemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
954a4556
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
DateUtil.go
util/DateUtil.go
+10
-0
NumberUtil.go
util/NumberUtil.go
+47
-0
No files found.
util/DateUtil.go
View file @
6c31b386
package
util
package
util
import
(
import
(
"math"
"time"
"time"
)
)
...
@@ -65,6 +66,15 @@ func TimeSubDays(t1, t2 time.Time) int {
...
@@ -65,6 +66,15 @@ func TimeSubDays(t1, t2 time.Time) int {
}
}
}
}
// TimeSubMinute t1比t2多多少分钟
func
TimeSubMinute
(
t1
,
t2
*
time
.
Time
)
int
{
if
t1
.
Location
()
.
String
()
!=
t2
.
Location
()
.
String
()
{
return
-
1
}
seconds
:=
t1
.
Sub
(
*
t2
)
.
Seconds
()
return
int
(
math
.
Ceil
(
seconds
/
60
))
//向上取整
}
func
MilSecond
(
time
time
.
Time
)
int64
{
func
MilSecond
(
time
time
.
Time
)
int64
{
return
time
.
UnixNano
()
/
1e6
return
time
.
UnixNano
()
/
1e6
}
}
util/NumberUtil.go
0 → 100644
View file @
6c31b386
package
util
import
(
"fmt"
"math/big"
"strconv"
)
type
numberUtilStruct
struct
{
}
var
NumberUtil
=
&
numberUtilStruct
{}
func
(
s
*
numberUtilStruct
)
Float64Format
(
p
float64
,
digit
int
)
float64
{
format
:=
"%."
+
strconv
.
Itoa
(
digit
)
+
"f"
value
,
_
:=
strconv
.
ParseFloat
(
fmt
.
Sprintf
(
format
,
p
),
64
)
return
value
}
type
bigDecimalStruct
struct
{
}
var
BigDecimal
=
&
bigDecimalStruct
{}
// Add 精度加法 a+b
func
(
s
*
bigDecimalStruct
)
Add
(
a
*
float64
,
b
*
float64
)
*
float64
{
r
,
_
:=
new
(
big
.
Float
)
.
Add
(
new
(
big
.
Float
)
.
SetFloat64
(
*
a
),
new
(
big
.
Float
)
.
SetFloat64
(
*
b
))
.
Float64
()
return
&
r
}
// Sub 精度减法 a-b
func
(
s
*
bigDecimalStruct
)
Sub
(
a
*
float64
,
b
*
float64
)
*
float64
{
r
,
_
:=
new
(
big
.
Float
)
.
Sub
(
new
(
big
.
Float
)
.
SetFloat64
(
*
a
),
new
(
big
.
Float
)
.
SetFloat64
(
*
b
))
.
Float64
()
return
&
r
}
// Mul 精度乘法 axb
func
(
s
*
bigDecimalStruct
)
Mul
(
a
*
float64
,
b
*
float64
)
*
float64
{
r
,
_
:=
new
(
big
.
Float
)
.
Mul
(
new
(
big
.
Float
)
.
SetFloat64
(
*
a
),
new
(
big
.
Float
)
.
SetFloat64
(
*
b
))
.
Float64
()
return
&
r
}
// Quo 精度除法 a/b
func
(
s
*
bigDecimalStruct
)
Quo
(
a
*
float64
,
b
*
float64
)
*
float64
{
r
,
_
:=
new
(
big
.
Float
)
.
Quo
(
new
(
big
.
Float
)
.
SetFloat64
(
*
a
),
new
(
big
.
Float
)
.
SetFloat64
(
*
b
))
.
Float64
()
return
&
r
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment