Debian Codegraph @

internal/events/reminder.go

raw symbols SCIP
1 // # Copyright (C) 2025 Francois Marier
2 //
3 // Email-Reminder is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 3 of the
6 // License, or (at your option) any later version.
7 //
8 // Email-Reminder is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Email-Reminder; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 package events
18
19 import (
20 "encoding/xml"
21 "strings"
22 )
23
24 type ReminderType string
25
26 const (
27 ReminderTypeSameDay ReminderType = "same day"
28 ReminderTypeDaysBefore ReminderType = "days before"
29 )
30
31 func (rt *ReminderType) UnmarshalText(text []byte) error {
32 v := strings.TrimSpace(strings.ToLower(string(text)))
33 switch v {
34 case string(ReminderTypeSameDay):
35 *rt = ReminderTypeSameDay
36 case string(ReminderTypeDaysBefore):
37 *rt = ReminderTypeDaysBefore
38 default:
39 *rt = ReminderType(v)
40 }
41 return nil
42 }
43
44 type Reminder struct {
45 XMLName xml.Name `xml:"reminder"`
46 Type ReminderType `xml:"type,attr"`
47 Days int `xml:",chardata"`
48 }