Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
hujiebin
hilo-common
Commits
ea614646
Commit
ea614646
authored
Mar 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下个月月底
parent
bee9c6a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
test_game_charge.go
script/test_game_charge.go
+1
-1
time.go
utils/time.go
+27
-1
No files found.
script/test_game_charge.go
View file @
ea614646
...
@@ -17,7 +17,7 @@ type Msg struct {
...
@@ -17,7 +17,7 @@ type Msg struct {
func
main
()
{
func
main
()
{
var
rpcLogs
[]
RpcLog
var
rpcLogs
[]
RpcLog
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"rpc_log_202303 "
)
.
Where
(
"`type` = 146"
)
.
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"rpc_log_202303 "
)
.
Where
(
"`type` = 146"
)
.
Where
(
"created_time >= ? and created_time < ?"
,
"2023-03-0
2"
,
"2023-03-03
"
)
.
Find
(
&
rpcLogs
)
.
Error
;
err
!=
nil
{
Where
(
"created_time >= ? and created_time < ?"
,
"2023-03-0
6"
,
"2023-03-07
"
)
.
Find
(
&
rpcLogs
)
.
Error
;
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
var
data
=
make
(
map
[
int
]
int
)
var
data
=
make
(
map
[
int
]
int
)
...
...
utils/time.go
View file @
ea614646
package
utils
package
utils
import
"time"
import
(
"github.com/jinzhu/now"
"time"
)
const
DEFAULT_LANG
=
"en"
const
DEFAULT_LANG
=
"en"
const
DATETIME_FORMAT
=
"2006-01-02 15:04:05"
const
DATETIME_FORMAT
=
"2006-01-02 15:04:05"
...
@@ -27,3 +30,26 @@ func GetLastDayOfWeek(t time.Time, n time.Weekday) time.Time {
...
@@ -27,3 +30,26 @@ func GetLastDayOfWeek(t time.Time, n time.Weekday) time.Time {
func
GetMonday
(
t
time
.
Time
)
time
.
Time
{
func
GetMonday
(
t
time
.
Time
)
time
.
Time
{
return
GetLastDayOfWeek
(
t
,
time
.
Monday
)
return
GetLastDayOfWeek
(
t
,
time
.
Monday
)
}
}
// 增加年/月
// 因为golang原生的Time.AddDate增加月份的时候有bug
func
AddDate
(
t
time
.
Time
,
years
int
,
months
int
)
time
.
Time
{
year
,
month
,
day
:=
t
.
Date
()
hour
,
min
,
sec
:=
t
.
Clock
()
// firstDayOfMonthAfterAddDate: years 年,months 月后的 那个月份的1号
firstDayOfMonthAfterAddDate
:=
time
.
Date
(
year
+
years
,
month
+
time
.
Month
(
months
),
1
,
hour
,
min
,
sec
,
t
.
Nanosecond
(),
t
.
Location
())
// firstDayOfMonthAfterAddDate 月份的最后一天
lastDay
:=
now
.
New
(
firstDayOfMonthAfterAddDate
)
.
EndOfMonth
()
.
Day
()
// 如果 t 的天 > lastDay,则设置为lastDay
// 如:t 为 2020-03-31 12:00:00 +0800,增加1个月,为4月31号
// 但是4月没有31号,则设置为4月最后一天lastDay(30号)
if
day
>
lastDay
{
day
=
lastDay
}
return
time
.
Date
(
year
+
years
,
month
+
time
.
Month
(
months
),
day
,
hour
,
min
,
sec
,
t
.
Nanosecond
(),
t
.
Location
())
}
\ No newline at end of file
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