10
"xelbot.com/reprogl/utils"
16
Company string `toml:"company"`
17
Link string `toml:"link,omitempty"`
18
Title string `toml:"title"`
19
StartDate time.Time `toml:"start"`
20
EndDate time.Time `toml:"end"`
22
CustomEmoji string `toml:"emoji,omitempty"`
25
func (jh JobHistory) Last() Job {
27
for _, job := range jh {
28
if job.StartDate.After(c.StartDate) {
36
func (jh JobHistory) Sort() JobHistory {
37
jhCopy := slices.Clone(jh)
41
return cmp.Compare(b.StartDate.Unix(), a.StartDate.Unix())
48
func (j *Job) LinkShort() (result string) {
49
matches := regexp.MustCompile(`^https?:\/\/([^\/]+)`).FindStringSubmatch(j.Link)
50
if matches != nil && matches[1] != "" {
57
func (j *Job) Start() string {
58
return utils.RuMonthName(j.StartDate.Month(), false) + " " + j.StartDate.Format("2006")
61
func (j *Job) End() string {
63
if j.EndDate.After(now) {
67
return utils.RuMonthName(j.EndDate.Month(), false) + " " + j.EndDate.Format("2006")
70
func (j *Job) Duration() string {
73
if j.EndDate.After(now) {
79
y0 := j.StartDate.Year()
82
m0 := int(j.StartDate.Month())
83
m1 := int(end.Month())
85
d0 := j.StartDate.Day()
88
return durationString(12*(y1-y0) + (m1 - m0) + int(0.5+float32(d1-d0)/30.0))
91
func (j *Job) Emoji() string {
93
if j.CustomEmoji == "electrical" {
109
return string(symbols)
112
func durationString(delta int) string {
117
return fmt.Sprintf("%d мес.", m)
122
monthPart = fmt.Sprintf(" %d мес.", m)
126
return "1 год" + monthPart
129
if y == 2 || y == 3 || y == 4 {
130
return fmt.Sprintf("%d года", y) + monthPart
133
if y >= 5 && y <= 20 {
134
return fmt.Sprintf("%d лет", y) + monthPart
138
return fmt.Sprintf("%d год", y) + monthPart
141
if y%10 == 0 || y%10 >= 5 {
142
return fmt.Sprintf("%d лет", y) + monthPart
145
return fmt.Sprintf("%d года", y) + monthPart