mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
fix(format): move time format to text
This commit is contained in:
parent
d0450179f9
commit
acf95aed5b
15
pkg/text/time.go
Normal file
15
pkg/text/time.go
Normal file
@ -0,0 +1,15 @@
|
||||
package text
|
||||
|
||||
import "time"
|
||||
|
||||
// Formats a unix timestamp to ISO 8601 date (yyyy-mm-dd)
|
||||
func FormatTime(i int) string {
|
||||
t := time.Unix(int64(i), 0)
|
||||
return t.Format("2006-01-02")
|
||||
}
|
||||
|
||||
// Formats a unix timestamp to ISO 8601 date (Mon 02 Jan 2006 03:04:05 PM MST)
|
||||
func FormatTimeQuery(i int) string {
|
||||
t := time.Unix(int64(i), 0)
|
||||
return t.Format("Mon 02 Jan 2006 03:04:05 PM MST")
|
||||
}
|
22
print.go
22
print.go
@ -79,7 +79,7 @@ func (q aurQuery) printSearch(start int) {
|
||||
}
|
||||
|
||||
if q[i].OutOfDate != 0 {
|
||||
toprint += bold(red(gotext.Get("(Out-of-date: %s)", formatTime(q[i].OutOfDate)))) + " "
|
||||
toprint += bold(red(gotext.Get("(Out-of-date: %s)", text.FormatTime(q[i].OutOfDate)))) + " "
|
||||
}
|
||||
|
||||
if pkg := localDB.Pkg(q[i].Name); pkg != nil {
|
||||
@ -287,11 +287,11 @@ func PrintInfo(a *rpc.Pkg) {
|
||||
text.PrintInfoValue(gotext.Get("Maintainer"), a.Maintainer)
|
||||
text.PrintInfoValue(gotext.Get("Votes"), fmt.Sprintf("%d", a.NumVotes))
|
||||
text.PrintInfoValue(gotext.Get("Popularity"), fmt.Sprintf("%f", a.Popularity))
|
||||
text.PrintInfoValue(gotext.Get("First Submitted"), formatTimeQuery(a.FirstSubmitted))
|
||||
text.PrintInfoValue(gotext.Get("Last Modified"), formatTimeQuery(a.LastModified))
|
||||
text.PrintInfoValue(gotext.Get("First Submitted"), text.FormatTimeQuery(a.FirstSubmitted))
|
||||
text.PrintInfoValue(gotext.Get("Last Modified"), text.FormatTimeQuery(a.LastModified))
|
||||
|
||||
if a.OutOfDate != 0 {
|
||||
text.PrintInfoValue(gotext.Get("Out-of-date"), formatTimeQuery(a.OutOfDate))
|
||||
text.PrintInfoValue(gotext.Get("Out-of-date"), text.FormatTimeQuery(a.OutOfDate))
|
||||
} else {
|
||||
text.PrintInfoValue(gotext.Get("Out-of-date"), "No")
|
||||
}
|
||||
@ -456,7 +456,7 @@ func (item *item) print(buildTime time.Time) {
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
} else {
|
||||
fd = formatTime(int(date.Unix()))
|
||||
fd = text.FormatTime(int(date.Unix()))
|
||||
if _, double, _ := cmdArgs.getArg("news", "w"); !double && !buildTime.IsZero() {
|
||||
if buildTime.After(date) {
|
||||
return
|
||||
@ -523,18 +523,6 @@ func printNewsFeed() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Formats a unix timestamp to ISO 8601 date (yyyy-mm-dd)
|
||||
func formatTime(i int) string {
|
||||
t := time.Unix(int64(i), 0)
|
||||
return t.Format("2006-01-02")
|
||||
}
|
||||
|
||||
// Formats a unix timestamp to ISO 8601 date (Mon 02 Jan 2006 03:04:05 PM MST)
|
||||
func formatTimeQuery(i int) string {
|
||||
t := time.Unix(int64(i), 0)
|
||||
return t.Format("Mon 02 Jan 2006 03:04:05 PM MST")
|
||||
}
|
||||
|
||||
const (
|
||||
redCode = "\x1b[31m"
|
||||
greenCode = "\x1b[32m"
|
||||
|
Loading…
Reference in New Issue
Block a user