Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions oslib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ func TestOsWrite(t *testing.T) {
t.Error(err)
}
}

func TestOsDateFmt(t *testing.T) {
s := "return os.date('!weekday=%w|%a|%A, month=%b|%B, year=%y, time=%I:%M|%H:%M:%S|%X, date=%Y-%m-%d|%x', 1136214245)"
L := NewState()
defer L.Close()
if err := L.DoString(s); err != nil {
t.Error(err)
} else {
ret := L.Get(-1)
expected := LString("weekday=1|mon|Monday, month=Jan|January, year=06, time=03:04|15:04:05|15:04:05, date=2006-01-02|01/02/06")
errorIfNotEqual(t, expected, ret)
}
}
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (fs *flagScanner) Next() (byte, bool) {
var cDateFlagToGo = map[byte]string{
'a': "mon", 'A': "Monday", 'b': "Jan", 'B': "January", 'c': "02 Jan 06 15:04 MST", 'd': "02",
'F': "2006-01-02", 'H': "15", 'I': "03", 'm': "01", 'M': "04", 'p': "PM", 'P': "pm", 'S': "05",
'x': "15/04/05", 'X': "15:04:05", 'y': "06", 'Y': "2006", 'z': "-0700", 'Z': "MST"}
'x': "01/02/06", 'X': "15:04:05", 'y': "06", 'Y': "2006", 'z': "-0700", 'Z': "MST"}

func strftime(t time.Time, cfmt string) string {
sc := newFlagScanner('%', "", "", cfmt)
Expand Down