about summary refs log tree commit diff stats
path: root/lib/format/format.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/format/format.go')
-rw-r--r--lib/format/format.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/format/format.go b/lib/format/format.go
index 30e8be7..1639886 100644
--- a/lib/format/format.go
+++ b/lib/format/format.go
@@ -47,8 +47,8 @@ type Ctx struct {
 	MsgIsMarked bool
 }
 
-func ParseMessageFormat(format string, timeFmt string, ctx Ctx) (string,
-	[]interface{}, error) {
+func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
+	thisYearTimeFmt string, ctx Ctx) (string, []interface{}, error) {
 	retval := make([]byte, 0, len(format))
 	var args []interface{}
 
@@ -144,7 +144,8 @@ func ParseMessageFormat(format string, timeFmt string, ctx Ctx) (string,
 			}
 			retval = append(retval, 's')
 			args = append(args,
-				dummyIfZeroDate(date.Local(), timeFmt))
+				dummyIfZeroDate(date.Local(),
+					timeFmt, thisDayTimeFmt, thisYearTimeFmt))
 		case 'D':
 			date := envelope.Date
 			if date.IsZero() {
@@ -152,7 +153,8 @@ func ParseMessageFormat(format string, timeFmt string, ctx Ctx) (string,
 			}
 			retval = append(retval, 's')
 			args = append(args,
-				dummyIfZeroDate(date.Local(), timeFmt))
+				dummyIfZeroDate(date.Local(),
+					timeFmt, thisDayTimeFmt, thisYearTimeFmt))
 		case 'f':
 			if envelope == nil {
 				return "", nil,
@@ -374,9 +376,20 @@ handle_end_error:
 		errors.New("reached end of string while parsing message format")
 }
 
-func dummyIfZeroDate(date time.Time, format string) string {
+func dummyIfZeroDate(date time.Time, format string, todayFormat string,
+	thisYearFormat string) string {
 	if date.IsZero() {
 		return strings.Repeat("?", len(format))
 	}
+	year, month, day := date.Date()
+	thisYear, thisMonth, thisDay := time.Now().Date()
+	if year == thisYear {
+		if month == thisMonth && day == thisDay && todayFormat != "" {
+			return date.Format(todayFormat)
+		}
+		if thisYearFormat != "" {
+			return date.Format(thisYearFormat)
+		}
+	}
 	return date.Format(format)
 }
dcc19e9708c'>ac0e9db5 ^
5b567348 ^
986eebff ^
3c435756 ^

88be3dbc ^
d672cdfc ^
5497090a ^

d672cdfc ^
57699011 ^
d672cdfc ^
ac0e9db5 ^
5b567348 ^
986eebff ^


ab6ed192 ^
b9011f34 ^
986eebff ^
7da71d03 ^
986eebff ^




986eebff ^
a2be26c8 ^
363be37f ^
3076bab4 ^
05d17773 ^
986eebff ^
3ba63579 ^
827898fc ^
7feea75b ^
986eebff ^




ac0e9db5 ^

b9011f34 ^
05d17773 ^

986eebff ^

b9011f34 ^
05d17773 ^
986eebff ^


5e938dc1 ^
7284d503 ^
88be3dbc ^
5e938dc1 ^
5497090a ^



5e938dc1 ^
57699011 ^
5e938dc1 ^
88be3dbc ^
b9011f34 ^
5497090a ^



b9011f34 ^
57699011 ^
b9011f34 ^
f1a3be1c ^

5e938dc1 ^
88be3dbc ^
db5c9550 ^
5e938dc1 ^
5497090a ^



5e938dc1 ^
d7494165 ^
5e938dc1 ^
f1a3be1c ^

c51043ab ^




047296d8 ^
05d17773 ^
c51043ab ^




047296d8 ^
05d17773 ^

c51043ab ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117