mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
webdav: add support for parsing more time formats
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -18,8 +18,10 @@ package webdavd
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
|
||||
@@ -43,6 +45,12 @@ const (
|
||||
var (
|
||||
certMgr *common.CertManager
|
||||
serviceStatus ServiceStatus
|
||||
timeFormats = []string{
|
||||
http.TimeFormat,
|
||||
"Mon, _2 Jan 2006 15:04:05 GMT",
|
||||
time.RFC850,
|
||||
time.ANSIC,
|
||||
}
|
||||
)
|
||||
|
||||
// ServiceStatus defines the service status
|
||||
@@ -352,3 +360,13 @@ func getConfigPath(name, configDir string) string {
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func parseTime(text string) (t time.Time, err error) {
|
||||
for _, layout := range timeFormats {
|
||||
t, err = time.Parse(layout, text)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user