This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the new fields (as of AVMs docs): * WindowOpenEnd * Boost * BoostEnd * Holiday * Summer As this makes the cli output quite long, I've added a verbose option to hide most of the new fields by default.
- Loading branch information
1 parent
4874fa4
commit 32732f8
Showing
7 changed files
with
155 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package fritz | ||
|
||
import ( | ||
"strconv" | ||
"time" | ||
) | ||
|
||
// FmtEpochSecond takes a int64, and formats it according to FmtCompact. | ||
func FmtEpochSecond(t int64, ref time.Time) string { | ||
return FmtCompact(time.Unix(1, 0), ref) | ||
} | ||
|
||
// FmtEpochSecondString takes a string, parses to to an epoch second and formats it according to FmtCompact. | ||
func FmtEpochSecondString(timeStamp string, ref time.Time) string { | ||
t, err := EpochToUnix(timeStamp) | ||
if err != nil { | ||
return "" | ||
} | ||
return FmtCompact(t, ref) | ||
} | ||
|
||
// EpochToUnix is equivalent to time.unix with zero nanoseconds, where the string argument passed to this function is parsed | ||
// as a base-10, 64-bit integer. It returns an error iff the argument could not be parsed. | ||
func EpochToUnix(epoch string) (time.Time, error) { | ||
i, err := strconv.ParseInt(epoch, 10, 64) | ||
return time.Unix(i, 0), err | ||
} | ||
|
||
// FmtCompact formats a given time t to a short form, given a reference time ref. It particular: | ||
// A simple time HH:MM:SS is displayed if t is in the same day as ref. | ||
// Day, month and time is returned if t is in the same year as ref. | ||
// Year, day, month and time is returned in all other cases. | ||
func FmtCompact(t, ref time.Time) string { | ||
refYear, refMonth, refDay := ref.Date() | ||
tYear, tMonth, tDay := t.Date() | ||
if refYear != tYear { | ||
return t.Format("Mon Jan 2 15:04:05 2006") | ||
} | ||
if refMonth != tMonth || refDay != tDay { | ||
return t.Format("Mon Jan 2 15:04:05") | ||
} | ||
return t.Format("15:04:05") | ||
} |
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