-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from Notifiarr/unstable
Crash fix
- Loading branch information
Showing
15 changed files
with
137 additions
and
62 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
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,64 @@ | ||
package mnd | ||
|
||
import ( | ||
"time" | ||
|
||
"golift.io/version" | ||
) | ||
|
||
const ( | ||
leapDay = 60 // day of year leap day falls on. | ||
altLeapDay = 366 | ||
) | ||
|
||
func today(when time.Time) int { | ||
switch today := when.YearDay(); { | ||
case !leapYear(when.Year()), today < leapDay: | ||
return today | ||
case today == leapDay: | ||
return altLeapDay | ||
default: | ||
return today - 1 | ||
} | ||
} | ||
|
||
func leapYear(year int) bool { | ||
return year%400 == 0 || (year%4 == 0 && year%100 != 0) | ||
} | ||
|
||
func emojiMonth(when time.Time) string { | ||
return map[time.Month]string{ | ||
time.January: "🤖", // | ||
time.February: "😻", // | ||
time.March: "🗼", // | ||
time.April: "🌧", // | ||
time.May: "🌸", // | ||
time.June: "🍄", // | ||
time.July: "🌵", // | ||
time.August: "🔥", // | ||
time.September: "🐸", // | ||
time.October: "🍁", // | ||
time.November: "👽", // | ||
time.December: "⛄", // | ||
}[when.Month()] | ||
} | ||
|
||
// TodaysEmoji returns an emoji specific to the month (or perhaps date). | ||
func TodaysEmoji() string { | ||
if emoji, ok := map[int]string{ | ||
1: "🎉", // January 1 | ||
45: "💝", // February 14 | ||
185: "🧨", // July 4 | ||
229: "🏄", // August 17 | ||
254: "⛑", // September 11 | ||
304: "🎃", // October 31 | ||
315: "🪖", // November 11 | ||
328: "🦃", // November 24 | ||
359: "🎄", // December 25 | ||
altLeapDay: "🤹", // February 29 (Leap Day) | ||
}[today(version.Started)]; ok { | ||
return emoji | ||
} | ||
|
||
return emojiMonth(version.Started) | ||
} |
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
Oops, something went wrong.