swift_mt_message/fields/field13.rs
1//! # Field 13: Time/Date Indication
2//!
3//! ## Purpose
4//! Provides time and date indication capabilities for payment processing with timezone offset information.
5//! These fields are critical for time-sensitive payments, settlement timing, and regulatory compliance
6//! in cross-border transactions requiring precise timing documentation.
7//!
8//! ## Options Overview
9//! - **Option C**: Time Indication with codes (SNDTIME, CLSTIME, etc.)
10//! - **Option D**: Complete Date/Time indication with UTC offset
11//!
12//! ## Format Specifications
13//! ### Option C Format
14//! - **Swift Format**: `/8c/4!n1!x4!n`
15//! - **Components**: Time indication code + Time + UTC offset sign + offset amount
16//!
17//! ### Option D Format
18//! - **Swift Format**: `6!n4!n1!x4!n`
19//! - **Components**: Date + Time + UTC offset sign + offset amount
20//!
21//! ## Valid Time Indication Codes (Option C)
22//! - **CLSTIME**: CLS Time - Funding payment deadline for CLS Bank (CET)
23//! - **RNCTIME**: Receive Time - TARGET2 payment credit time at receiving central bank
24//! - **SNDTIME**: Send Time - TARGET2 payment debit time at sending central bank
25//! - **REJTIME**: Rejection Time - Payment rejection or return timestamp
26//! - **CUTTIME**: Cut-off Time - Latest processing time for payments
27//!
28//! ## Usage Guidelines
29//! ### When to Use Option C (Time Indication)
30//! - **Settlement Systems**: CLS Bank settlement timing coordination
31//! - **TARGET2 Payments**: European central bank payment timing
32//! - **Cut-off Management**: Processing deadline specifications
33//! - **Event Timing**: Specific time-based payment events
34//!
35//! ### When to Use Option D (Date/Time Indication)
36//! - **Transaction Timestamping**: Precise recording of payment events
37//! - **Audit Documentation**: Comprehensive temporal records for compliance
38//! - **Cross-Border Coordination**: Time coordination across different time zones
39//! - **Regulatory Compliance**: Meeting time-stamping requirements for reporting
40//!
41//! ## Network Validation Rules
42//! - **Time Format**: Must be valid time in HHMM format (00:00 to 23:59)
43//! - **Date Format**: Must be valid calendar date in YYMMDD format (Option D)
44//! - **Offset Sign**: Must be exactly + (ahead of UTC) or - (behind UTC)
45//! - **Offset Range**: UTC offset must be within valid timezone ranges (typically ±13 hours)
46//! - **Code Validation**: Time indication codes must be valid and recognized (Option C)
47//!
48//! ## Business Applications
49//! ### Settlement Coordination
50//! - **Timezone Management**: UTC offset enables precise time zone identification
51//! - **Multiple Indications**: Multiple time indications can be provided in sequences
52//! - **Settlement Timing**: Coordination of settlement timing across time zones
53//! - **Processing Windows**: Definition of processing cut-off times
54//!
55//! ### Regulatory Compliance
56//! - **Timestamp Requirements**: Meeting regulatory time-stamping requirements
57//! - **Audit Trails**: Creating comprehensive timestamp records for compliance
58//! - **Cross-Border Rules**: Supporting international payment timing regulations
59//! - **System Integration**: Enabling time-aware processing across systems
60//!
61//! ## Regional Considerations
62//! - **European Payments**: CET/CEST timing for TARGET2 and SEPA systems
63//! - **US Payments**: EST/EDT timing for Federal Reserve systems
64//! - **Asian Markets**: Local time zones for regional clearing systems
65//! - **Global Coordination**: UTC reference for international settlements
66//!
67//! ## Timezone Offset Guidelines
68//! - **Standard Offsets**: Most timezone offsets are in full hour increments
69//! - **Special Cases**: Some regions use 30 or 45-minute offsets
70//! - **Daylight Saving**: Offsets change with daylight saving time transitions
71//! - **UTC Reference**: All offsets calculated relative to Coordinated Universal Time
72//!
73//! ## Error Prevention Guidelines
74//! - **Time Validation**: Ensure time is valid 24-hour format
75//! - **Date Validation**: Verify date is valid and within reasonable business range
76//! - **Offset Accuracy**: Confirm timezone offset matches actual timezone
77//! - **Code Selection**: Use appropriate time indication code for context (Option C)
78//! - **Business Logic**: Ensure timing aligns with settlement windows and business processes
79//!
80//! ## Related Fields Integration
81//! - **Field 32A**: Value Date (settlement date coordination)
82//! - **Field 30**: Execution Date (date-only specifications)
83//! - **Field 72**: Sender to Receiver Information (additional timing details)
84//! - **Block Headers**: Message timestamps (system-level timing)
85//!
86//! ## Technical Implementation
87//! - **Date Handling**: Uses `chrono::NaiveDate` for robust date parsing
88//! - **Time Handling**: Uses `chrono::NaiveTime` for time validation
89//! - **Offset Storage**: String format for flexible UTC offset representation
90//! - **Validation**: Automatic format validation through Swift macro system
91//!
92//! ## See Also
93//! - Swift FIN User Handbook: Date/Time Specifications
94//! - ISO 8601: International Date/Time Standards
95//! - SWIFT Network Rules: Timestamp Requirements
96//! - Regional Payment Guides: Local Time Zone Considerations
97
98use chrono::{NaiveDate, NaiveTime};
99use serde::{Deserialize, Serialize};
100use swift_mt_message_macros::SwiftField;
101
102/// **Field 13C: Time Indication**
103///
104/// Time indication variant of [Field 13 module](index.html). Specifies time indication related
105/// to payment processing with timezone offset and specific timing codes.
106///
107/// **Components:**
108/// - Time indication code (/8c/, e.g., SNDTIME, CLSTIME)
109/// - Time (4!n, HHMM format)
110/// - UTC offset sign (1!x, + or -)
111/// - UTC offset amount (4!n, HHMM format)
112///
113/// For complete documentation, see the [Field 13 module](index.html).
114#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
115pub struct Field13C {
116 /// Time indication code with slashes
117 ///
118 /// Format: /8c/ - Valid codes: SNDTIME, CLSTIME, RNCTIME, REJTIME, CUTTIME
119 /// Specifies the type of time being indicated
120 #[component("/8c/")]
121 pub code: String,
122
123 /// Time in 24-hour format
124 ///
125 /// Format: 4!n (HHMM) - Must be valid time (00:00 to 23:59)
126 /// Represents the actual time for the indicated event
127 #[component("4!n")]
128 pub time: String,
129
130 /// Timezone offset sign
131 ///
132 /// Format: 1!x - Must be + (ahead of UTC) or - (behind UTC)
133 /// Indicates direction of timezone offset from UTC
134 #[component("1!x")]
135 pub sign: String,
136
137 /// Timezone offset amount
138 ///
139 /// Format: 4!n (HHMM) - Hours (00-13), Minutes (00-59)
140 /// Specifies the offset from UTC time
141 #[component("4!n")]
142 pub offset: String,
143}
144
145/// **Field 13D: Date/Time Indication**
146///
147/// Complete date/time variant of [Field 13 module](index.html). Specifies complete date and time
148/// indication with UTC offset for precise timestamp documentation.
149///
150/// **Components:**
151/// - Date (6!n, YYMMDD format)
152/// - Time (4!n, HHMM format)
153/// - UTC offset sign (1!x, + or -)
154/// - UTC offset amount (4!n)
155///
156/// For complete documentation, see the [Field 13 module](index.html).
157#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
158pub struct Field13D {
159 /// Date component in YYMMDD format
160 ///
161 /// Format: 6!n - Must be valid calendar date
162 /// Used for complete date specification with time
163 #[component("6!n")]
164 pub date: NaiveDate,
165
166 /// Time component in HHMM format
167 ///
168 /// Format: 4!n - 24-hour clock (00:00 to 23:59)
169 /// Provides precise time specification
170 #[component("4!n")]
171 pub time: NaiveTime,
172
173 /// UTC offset direction sign
174 ///
175 /// Format: 1!x - Must be + (ahead of UTC) or - (behind UTC)
176 /// Indicates timezone relationship to UTC
177 #[component("1!x")]
178 pub offset_sign: char,
179
180 /// UTC offset amount
181 ///
182 /// Format: 4!n - HHMM format for hours and minutes
183 /// Specifies the numerical offset from UTC
184 #[component("4!n")]
185 pub offset_seconds: String,
186}