Used to ensure that an AI component conforms to the YYYYMMDD or YYYYMM00 formats.
56{
57
58
59#define XX(d) ( (data[d] - '0') * 10 + (data[d+1] - '0') )
60#define YY ( XX(0) * 100 + XX(2) )
61#define MM XX(4)
62#define DD XX(6)
63
64
65 static const unsigned char daysinmonth[] =
66 { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
67
68 size_t pos;
69 unsigned char maxdd;
70
71 assert(data);
72
73
74
75
76
77 for (pos = 0; pos < 8 && data[pos]; pos++) {
81 pos,
82 1
83 );
84 }
85
86
87
88
89
93 0,
94 pos + (data[pos] ? 1 : 0)
95 );
96
97
98
99
100
104 4,
105 2
106 );
107
108
109
110
111
112 if (MM == 2) {
113 maxdd = ((YY % 4 == 0 && YY % 100 != 0) || YY % 400 == 0) ? 29 : 28;
114 } else {
115 maxdd = daysinmonth[MM - 1];
116 }
117
121 6,
122 2
123 );
124
126
127}
#define GS1_LINTER_UNLIKELY(x)
Implemention may provide hint to the compiler that the expression is likely to be false.
Definition gs1syntaxdictionary-utils.h:76
#define GS1_LINTER_RETURN_ERROR(error, position, length)
Return from a linter indicating that a problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:103
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:88
@ GS1_LINTER_ILLEGAL_DAY
The date contains an illegal day of the month.
Definition gs1syntaxdictionary.h:114
@ GS1_LINTER_DATE_TOO_LONG
The date is too long for YYMMDD format.
Definition gs1syntaxdictionary.h:106
@ GS1_LINTER_ILLEGAL_MONTH
The date contains an illegal month of the year.
Definition gs1syntaxdictionary.h:113
@ GS1_LINTER_DATE_TOO_SHORT
The date is too short for YYMMDD format.
Definition gs1syntaxdictionary.h:105
@ GS1_LINTER_NON_DIGIT_CHARACTER
A non-digit character was found where a digit is expected.
Definition gs1syntaxdictionary.h:78