-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #29 date comparison before uploading file
- Loading branch information
Showing
18 changed files
with
185 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package tzone | ||
|
||
import ( | ||
"strings" | ||
"sync" | ||
"time" | ||
) | ||
|
||
var ( | ||
_local *time.Location | ||
_err error | ||
onceSetLocal sync.Once | ||
) | ||
|
||
func Local() (*time.Location, error) { | ||
onceSetLocal.Do(func() { | ||
var tz string | ||
tz, _err = getTimezoneName() | ||
if _err != nil { | ||
return | ||
} | ||
|
||
_local, _err = time.LoadLocation(strings.TrimSuffix(tz, "\n")) | ||
}) | ||
return _local, _err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build darwin | ||
|
||
package tzone | ||
|
||
import ( | ||
"os/exec" | ||
) | ||
|
||
func getTimezoneName() (string, error) { | ||
cmd := exec.Command("systemsetup", "-gettimezone") | ||
output, err := cmd.Output() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return string(output), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build unix | ||
|
||
package tzone | ||
|
||
import "os" | ||
|
||
func getTimezoneName() (string, error) { | ||
data, err := os.ReadFile("/etc/timezone") | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(data), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build windows | ||
|
||
package tzone | ||
|
||
import ( | ||
"golang.org/x/sys/windows/registry" | ||
) | ||
|
||
func getTimezoneName() (string, error) { | ||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Control\TimeZoneInformation`, registry.QUERY_VALUE) | ||
if err != nil { | ||
return "", err | ||
} | ||
defer key.Close() | ||
|
||
var timeZoneName string | ||
if val, valType, err := key.GetStringValue("TimeZoneKeyName"); err == nil && valType == registry.SZ { | ||
timeZoneName = val | ||
} else { | ||
return "", err | ||
} | ||
return timeZoneName, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters