+ // Clear the screen using ANSI escape codes
+ fmt.Print("\033[H\033[2J")
+ // Print current time for clarity and context
+ fmt.Print(time.Now(), "\n\n")
+ // Calculate the percentage how many seconds this year has progressed
+ percentage := calcPercentage()
+ // Convert percentage number into a human readable graph
+ printGraphic(percentage)
+ // Calculate required delay so this updates once every second on the second
+func calcPercentage() float64 {
+ t1 := Date(ct.Year(), 1, 1)
+ ny := ct.AddDate(1, 0, 0)
+ t2 := Date(ny.Year(), 1, 1)
+ // Get all the seconds in a year
+ seconds := t2.Sub(t1).Seconds()
+ // Calculate the difference in seconds between ct and ny
+ tdiff := ct.Sub(t1).Seconds()
+ // Return the percentage
+ return calcPercentageFloat64(seconds, tdiff)
+func calcPercentageFloat64(full float64, part float64) float64 {
+ return part / (full / 100)
+func Date(year, month, day int) time.Time {
+ return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
+func printGraphic(percentage float64) {
+ workPerc = workPerc - 2
+ fmt.Print("| ", percentage, "%\n")
+func calcDelay() time.Duration {
+ ft := ct.Add(1 * time.Second)
+ rt := time.Date(ft.Year(), ft.Month(), ft.Day(), ft.Hour(), ft.Minute(), ft.Second(), int(0), time.UTC)