MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / GetSendTime

Method GetSendTime

api/pkg/requests/bulk_message_request.go:26–55  ·  view source on GitHub ↗

GetSendTime parses the raw SendTime string into a *time.Time. For timezone-naive formats, the time is interpreted in the given location. For RFC3339 (which includes an offset), the embedded offset is used.

(location *time.Location)

Source from the content-addressed store, hash-verified

24// For timezone-naive formats, the time is interpreted in the given location.
25// For RFC3339 (which includes an offset), the embedded offset is used.
26func (input *BulkMessage) GetSendTime(location *time.Location) *time.Time {
27 raw := strings.TrimSpace(input.SendTime)
28 if raw == "" {
29 return nil
30 }
31
32 if location == nil {
33 location = time.UTC
34 }
35
36 // RFC3339 already contains timezone offset, parse without location
37 if t, err := time.Parse(time.RFC3339, raw); err == nil {
38 utc := t.UTC()
39 return &utc
40 }
41
42 // Naive formats: interpret in the user's location
43 naiveFormats := []string{
44 "2006-01-02T15:04:05",
45 "2006-01-02 15:04:05",
46 }
47
48 for _, format := range naiveFormats {
49 if t, err := time.ParseInLocation(format, raw, location); err == nil {
50 utc := t.UTC()
51 return &utc
52 }
53 }
54 return nil
55}
56
57// Sanitize sets defaults to BulkMessage
58func (input *BulkMessage) Sanitize() *BulkMessage {

Callers 4

ToMessageSendParamsMethod · 0.95
parseXlsxMethod · 0.95
validateMessagesMethod · 0.80
StoreMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected