Skip to content

Commit e9e888b

Browse files
authored
Merge pull request mouredev#2674 from hozlucas28/Solution-14-Go
#14 - Go
2 parents eab7cdf + 8989e9d commit e9e888b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Roadmap/14 - FECHAS/go/hozlucas28.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
func main() {
9+
/*
10+
Dates...
11+
*/
12+
13+
fmt.Println("Dates...")
14+
15+
var today time.Time = time.Now()
16+
var bornDate time.Time = time.Date(2002, time.February, 20, 0, 0, 0, 0, time.UTC)
17+
18+
fmt.Printf("\nToday is: %v\n", today)
19+
fmt.Printf("\nLucas Hoz born date: %v\n", bornDate)
20+
21+
var yearsBetweenDates int = today.Year() - bornDate.Year()
22+
fmt.Printf("\nYears between today and born date: %d years\n", yearsBetweenDates)
23+
24+
fmt.Println("\n# ---------------------------------------------------------------------------------- #")
25+
26+
/*
27+
Additional challenge...
28+
*/
29+
30+
fmt.Println("\nAdditional challenge...")
31+
32+
fmt.Printf("\nDay, month, and year: %d, %d, and %d\n", bornDate.Day(), bornDate.Month(), bornDate.Year())
33+
34+
fmt.Printf("\nHours, minutes, and seconds: %d hours, %d minutes, and %d seconds\n", bornDate.Hour(), bornDate.Minute(), bornDate.Second())
35+
36+
fmt.Printf("\nDay of the year: %d\n", bornDate.YearDay())
37+
38+
fmt.Printf("\nDay of the week (weeks starts on sunday): %d\n", bornDate.Weekday()+1)
39+
40+
fmt.Printf("\nMonth name: %s\n", bornDate.Local().Month())
41+
}

0 commit comments

Comments
 (0)