Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
homekeeper
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Peter Cheng
homekeeper
Commits
a3bb5080
Commit
a3bb5080
authored
Jun 19, 2019
by
Peter Cheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正時間日期前面未加上零之問題
parent
c71bc406
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
punchclock.go
controllers/punchclock.go
+15
-15
No files found.
controllers/punchclock.go
View file @
a3bb5080
...
@@ -18,15 +18,15 @@ import (
...
@@ -18,15 +18,15 @@ import (
func
CalcTime
(
c
*
gin
.
Context
)
{
func
CalcTime
(
c
*
gin
.
Context
)
{
params
:=
getPunchclockParams
(
c
)
params
:=
getPunchclockParams
(
c
)
beginYear
:=
params
.
GetBegin
()
.
GetYear
()
beginYear
:=
params
.
GetBegin
()
.
GetYear
()
beginMonth
:=
params
.
GetBegin
()
.
GetMonth
(
)
beginMonth
:=
appendZero
(
params
.
GetBegin
()
.
GetMonth
()
)
beginDay
:=
params
.
GetBegin
()
.
GetDay
(
)
beginDay
:=
appendZero
(
params
.
GetBegin
()
.
GetDay
()
)
beginHour
:=
params
.
GetBegin
()
.
GetHour
(
)
beginHour
:=
appendZero
(
params
.
GetBegin
()
.
GetHour
()
)
beginMinute
:=
params
.
GetBegin
()
.
GetMinute
(
)
beginMinute
:=
appendZero
(
params
.
GetBegin
()
.
GetMinute
()
)
endYear
:=
params
.
GetEnd
()
.
GetYear
()
endYear
:=
params
.
GetEnd
()
.
GetYear
()
endMonth
:=
params
.
GetEnd
()
.
GetMonth
(
)
endMonth
:=
appendZero
(
params
.
GetEnd
()
.
GetMonth
()
)
endDay
:=
params
.
GetEnd
()
.
GetDay
(
)
endDay
:=
appendZero
(
params
.
GetEnd
()
.
GetDay
()
)
endHour
:=
params
.
GetEnd
()
.
GetHour
(
)
endHour
:=
appendZero
(
params
.
GetEnd
()
.
GetHour
()
)
endMinute
:=
params
.
GetEnd
()
.
GetMinute
(
)
endMinute
:=
appendZero
(
params
.
GetEnd
()
.
GetMinute
()
)
beginTime
,
_
:=
strconv
.
Atoi
(
beginHour
+
beginMinute
)
beginTime
,
_
:=
strconv
.
Atoi
(
beginHour
+
beginMinute
)
endTime
,
_
:=
strconv
.
Atoi
(
endHour
+
endMinute
)
endTime
,
_
:=
strconv
.
Atoi
(
endHour
+
endMinute
)
...
@@ -43,8 +43,8 @@ func CalcTime(c *gin.Context) {
...
@@ -43,8 +43,8 @@ func CalcTime(c *gin.Context) {
}
else
{
//沒跨午休
}
else
{
//沒跨午休
diffHour
,
diffMinute
=
calcTime
(
beginHour
,
endHour
,
beginMinute
,
endMinute
,
false
)
diffHour
,
diffMinute
=
calcTime
(
beginHour
,
endHour
,
beginMinute
,
endMinute
,
false
)
}
}
_beginMonth
:=
appendZero
(
beginMonth
)
_beginMonth
:=
beginMonth
_beginDay
:=
appendZero
(
beginDay
)
_beginDay
:=
beginDay
if
isHoliday
(
beginYear
,
_beginMonth
,
_beginDay
)
{
if
isHoliday
(
beginYear
,
_beginMonth
,
_beginDay
)
{
diffDay
=
0
diffDay
=
0
diffHour
=
0
diffHour
=
0
...
@@ -59,7 +59,7 @@ func CalcTime(c *gin.Context) {
...
@@ -59,7 +59,7 @@ func CalcTime(c *gin.Context) {
_diffHour
,
_diffMinute
=
calcTime
(
beginHour
,
"18"
,
beginMinute
,
"0"
,
false
)
_diffHour
,
_diffMinute
=
calcTime
(
beginHour
,
"18"
,
beginMinute
,
"0"
,
false
)
}
}
diffDay
=
calcDate
(
beginYear
,
beginMonth
,
beginDay
,
endYear
,
endMonth
,
endDay
)
diffDay
=
calcDate
(
beginYear
,
beginMonth
,
beginDay
,
endYear
,
endMonth
,
endDay
)
if
endTime
<
120
0
{
//有跨午休
if
endTime
>
133
0
{
//有跨午休
diffHour
,
diffMinute
=
calcTime
(
"8"
,
endHour
,
"30"
,
endMinute
,
true
)
diffHour
,
diffMinute
=
calcTime
(
"8"
,
endHour
,
"30"
,
endMinute
,
true
)
}
else
{
//沒跨午休
}
else
{
//沒跨午休
diffHour
,
diffMinute
=
calcTime
(
"8"
,
endHour
,
"30"
,
endMinute
,
false
)
diffHour
,
diffMinute
=
calcTime
(
"8"
,
endHour
,
"30"
,
endMinute
,
false
)
...
@@ -120,10 +120,10 @@ func isHoliday(year string, month string, day string) bool {
...
@@ -120,10 +120,10 @@ func isHoliday(year string, month string, day string) bool {
func
calcDate
(
beginYear
string
,
beginMonth
string
,
beginDay
string
,
endYear
string
,
endMonth
string
,
endDay
string
)
int
{
func
calcDate
(
beginYear
string
,
beginMonth
string
,
beginDay
string
,
endYear
string
,
endMonth
string
,
endDay
string
)
int
{
cfg
:=
env
.
GetEnv
()
cfg
:=
env
.
GetEnv
()
diffDay
:=
0
diffDay
:=
0
_beginMonth
:=
appendZero
(
beginMonth
)
_beginMonth
:=
beginMonth
_beginDay
:=
appendZero
(
beginDay
)
_beginDay
:=
beginDay
_endMonth
:=
appendZero
(
endMonth
)
_endMonth
:=
endMonth
_endDay
:=
appendZero
(
endDay
)
_endDay
:=
endDay
checkTime
:=
beginYear
+
"-"
+
_beginMonth
+
"-"
+
_beginDay
+
" 00:00:00"
checkTime
:=
beginYear
+
"-"
+
_beginMonth
+
"-"
+
_beginDay
+
" 00:00:00"
begin
,
_
:=
time
.
ParseInLocation
(
cfg
.
TimeFormat
,
checkTime
,
time
.
Local
)
begin
,
_
:=
time
.
ParseInLocation
(
cfg
.
TimeFormat
,
checkTime
,
time
.
Local
)
checkTime
=
endYear
+
"-"
+
_endMonth
+
"-"
+
_endDay
+
" 00:00:00"
checkTime
=
endYear
+
"-"
+
_endMonth
+
"-"
+
_endDay
+
" 00:00:00"
...
...
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