initial page
This commit is contained in:
83
domain/experience.go
Normal file
83
domain/experience.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Company struct {
|
||||
Name string `json:"name"`
|
||||
City string `json:"city"`
|
||||
Link string `json:"link"`
|
||||
Logo string `json:"logo"`
|
||||
Description string `json:"description"`
|
||||
LocationLink string `json:"location_link"`
|
||||
}
|
||||
|
||||
type Stack struct {
|
||||
Name string `json:"name"`
|
||||
Logo string `json:"logo"`
|
||||
Link string `json:"link"`
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Objectives []string `json:"objectives"`
|
||||
FrontendStack []Stack `json:"frontend_stack"`
|
||||
BackendStack []Stack `json:"backend_stack"`
|
||||
InfrastructureStack []Stack `json:"infrastructure_stack"`
|
||||
}
|
||||
|
||||
type Experience struct {
|
||||
Company Company `json:"company"`
|
||||
Job Job `json:"job"`
|
||||
StartDate time.Time `json:"start_date"`
|
||||
EndDate time.Time `json:"end_date"`
|
||||
}
|
||||
|
||||
func (e Experience) Duration() string {
|
||||
end := e.EndDate
|
||||
if e.EndDate.IsZero() {
|
||||
end = time.Now()
|
||||
}
|
||||
|
||||
duration := end.Sub(e.StartDate)
|
||||
years := int(duration.Hours() / (24 * 365))
|
||||
months := int(duration.Hours()/(24*30)) - years*12
|
||||
|
||||
label := ""
|
||||
if years == 1 {
|
||||
label += "1 year"
|
||||
}
|
||||
|
||||
if years > 1 {
|
||||
label += fmt.Sprintf("%d years", years)
|
||||
}
|
||||
|
||||
if label != "" {
|
||||
label += ", "
|
||||
}
|
||||
|
||||
if months == 1 {
|
||||
label += "1 month"
|
||||
}
|
||||
|
||||
if months > 1 {
|
||||
label += fmt.Sprintf("%d months", months)
|
||||
}
|
||||
|
||||
return label
|
||||
}
|
||||
|
||||
func (e Experience) GetStartDate() string {
|
||||
return e.StartDate.Format("Jan 2006")
|
||||
}
|
||||
|
||||
func (e Experience) GetEndDate() string {
|
||||
if e.EndDate.IsZero() {
|
||||
return "Present"
|
||||
}
|
||||
|
||||
return e.EndDate.Format("Jan 2006")
|
||||
}
|
||||
Reference in New Issue
Block a user