Make it possible to specify what timezone to parse timestamps in

This commit is contained in:
Shannon Wynter
2018-03-20 15:07:44 +10:00
parent 427467931c
commit 4772add9d0
3 changed files with 26 additions and 22 deletions

6
ftp.go
View File

@@ -30,6 +30,9 @@ type ServerConn struct {
// Do not use EPSV mode
DisableEPSV bool
// Timezone that the server is in
Location *time.Location
conn *textproto.Conn
host string
timeout time.Duration
@@ -83,6 +86,7 @@ func DialTimeout(addr string, timeout time.Duration) (*ServerConn, error) {
host: remoteAddr.IP.String(),
timeout: timeout,
features: make(map[string]string),
Location: time.UTC,
}
_, _, err = c.conn.ReadResponse(StatusReady)
@@ -374,7 +378,7 @@ func (c *ServerConn) List(path string) (entries []*Entry, err error) {
scanner := bufio.NewScanner(r)
now := time.Now()
for scanner.Scan() {
entry, err := parser(scanner.Text(), now)
entry, err := parser(scanner.Text(), now, c.Location)
if err == nil {
entries = append(entries, entry)
}