1515 textColor* : Color
1616 timeColor* : Color
1717 titleColor* : Color
18+ startWithToday* : bool
1819
1920 App * = ref object of AppRoot
2021 appConfig* : AppConfig
@@ -36,17 +37,21 @@ proc get*(self: App, context: ExecutionContext): string =
3637 let time = & " ^({ self.appConfig.baseFontSize} ,{ self.appConfig.timeColor.toHtmlHex ()} ) "
3738 let events = self.appConfig.events
3839 let timezone = self.getTimezone (events)
39- let todayTs = epochTime ().Timestamp
40- let today = format (todayTs, titleFormat, tzName = timezone)
4140
4241 proc h1 (text: string ): string = & " { title} { text} \n { normal} \n "
4342 proc formatDay (day: string ): string = format (parseTs (" {year/4}-{month/2}-{day/2}" , day), titleFormat)
4443
45- var currentDay = format (todayTs, " {year/4}-{month/2}-{day/2} " , tzName = timezone)
44+ let noEvents = events == nil or events.kind != JArray or events.len == 0
4645
47- result = h1 (today)
46+ result = " "
4847
49- if events == nil or events.kind != JArray or events.len == 0 :
48+ var currentDay = " "
49+ if self.appConfig.startWithToday or noEvents:
50+ let todayTs = epochTime ().Timestamp
51+ result &= h1 (format (todayTs, titleFormat, tzName = timezone))
52+ currentDay = format (todayTs, " {year/4}-{month/2}-{day/2}" , tzName = timezone)
53+
54+ if noEvents:
5055 result &= & " No events found\n "
5156 return
5257
@@ -61,10 +66,9 @@ proc get*(self: App, context: ExecutionContext): string =
6166 let withTime = " T" in startDay
6267 let startDate = startDay.split (" T" )[0 ]
6368
64- if startDate > currentDay:
65- if not hasAny:
69+ if startDate != currentDay: # new day, past or future
70+ if not hasAny and startDate != currentDay and self.appConfig.startWithToday :
6671 result &= " No events today\n "
67-
6872 result &= " \n " & h1 (formatDay (startDate))
6973 currentDay = startDate
7074
0 commit comments