| 
									
										
										
										
											2018-12-14 15:14:34 +03:00
										 |  |  | // Copyright © 2018 Inanc Gumus | 
					
						
							|  |  |  | // Learn Go Programming Course | 
					
						
							|  |  |  | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ | 
					
						
							|  |  |  | // | 
					
						
							| 
									
										
										
										
											2019-10-30 19:34:44 +03:00
										 |  |  | // For more tutorials  : https://learngoprogramming.com | 
					
						
							|  |  |  | // In-person training  : https://www.linkedin.com/in/inancgumus/ | 
					
						
							|  |  |  | // Follow me on twitter: https://twitter.com/inancgumus | 
					
						
							| 
									
										
										
										
											2018-12-14 15:14:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"time" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/inancgumus/screen" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | 	screen.Clear() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for { | 
					
						
							|  |  |  | 		screen.MoveTopLeft() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		now := time.Now() | 
					
						
							|  |  |  | 		hour, min, sec := now.Hour(), now.Minute(), now.Second() | 
					
						
							|  |  |  | 		ssec := now.Nanosecond() / 1e8 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		clock := [...]placeholder{ | 
					
						
							|  |  |  | 			digits[hour/10], digits[hour%10], | 
					
						
							|  |  |  | 			colon, | 
					
						
							|  |  |  | 			digits[min/10], digits[min%10], | 
					
						
							|  |  |  | 			colon, | 
					
						
							|  |  |  | 			digits[sec/10], digits[sec%10], | 
					
						
							|  |  |  | 			dot, | 
					
						
							|  |  |  | 			digits[ssec], | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for line := range clock[0] { | 
					
						
							|  |  |  | 			for index, digit := range clock { | 
					
						
							|  |  |  | 				next := clock[index][line] | 
					
						
							|  |  |  | 				if (digit == colon || digit == dot) && sec%2 == 0 { | 
					
						
							|  |  |  | 					next = "   " | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				fmt.Print(next, "  ") | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			fmt.Println() | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const splitSecond = time.Second / 10 | 
					
						
							|  |  |  | 		time.Sleep(splitSecond) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |