govote/voting/vote/vote.go
2024-05-13 10:45:38 +02:00

33 lines
571 B
Go

package vote
import (
"fmt"
"time"
)
type Vote struct {
Elector string
Choice Choice
timestamp time.Time
}
func NewVote(elector string, choice Choice) Vote {
return Vote{
Elector: elector,
Choice: choice,
timestamp: time.Now().UTC(),
}
}
func NewVoteWithTimestamp(elector string, choice Choice, timestamp time.Time) Vote {
return Vote{
Elector: elector,
Choice: choice,
timestamp: timestamp,
}
}
func (vote Vote) String() string {
return fmt.Sprintf("%s %s %s", vote.timestamp.Format(time.DateTime), vote.Choice, vote.Elector)
}