161 static const char*
const kMonths[] = {
162 "0",
"January",
"February",
"March",
"April",
"May",
"June",
163 "July",
"August",
"September",
"October",
"November",
"December"
165 static const int kNumMonths =
sizeof (kMonths) /
sizeof (
char*);
170 unsigned int depth = 0;
171 vector<pair<SIZE_TYPE, SIZE_TYPE> > starts;
178 if (++it ==
format.end()) {
180 "CDate_std::GetDate(): incomplete % expression",
188 else if (*it ==
'{') {
190 starts.push_back(make_pair(
label->size(),
193 }
else if (*it ==
'}') {
196 "CDate_std::GetDate(): unbalanced %}",
202 }
else if (*it ==
'|') {
207 unsigned int depth2 = 0;
209 while (++it !=
format.end() && *it !=
'%')
213 "CDate_std::GetDate(): unbalanced %{",
214 starts.back().second);
224 }
else if (*it ==
'{') {
231 unsigned int length = 0;
233 while (
isdigit((
unsigned char)(*it))) {
234 length = length * 10 + *it -
'0';
235 if (++it ==
format.end()) {
237 "CDate_std::GetDate(): incomplete % expression",
252 "CDate_std::GetDate(): unrecognized format specifier",
259 if (
value >= kNumMonths) {
262 name = kMonths[
value];
265 label->append(name, length);
269 }
else if (*it ==
'S') {
279 size_t zeropad = length < s.length() ? 0 : length-s.length();
280 size_t start = (length > 0 && length < s.length() ) ? s.size() - length : 0;
282 label->append(zeropad,
'0');
283 label->append(s, start, s.size() - start);
288 label->erase(starts.back().first);
290 unsigned int depth2 = 0;
292 while (++it !=
format.end() && *it !=
'%')
295 if (
depth > 0 || depth2 > 0) {
297 "CDate_std::GetDate(): unbalanced %{",
298 starts.back().second);
301 string(
"CDate_std::GetDate():"
302 " missing required field %")
303 + request, it -
format.begin() - 1);
306 if (*it ==
'|' && depth2 == 0) {
308 }
else if (*it ==
'}') {
312 "CDate_std::GetDate(): unbalanced %}",
321 }
else if (*it ==
'{') {
CDate::ECompare Compare(const CDate_std &date) const
Indicate how *this relates to another date.
void SetToTime(const CTime &time, CDate::EPrecision prec=CDate::ePrecision_second)
CTime AsCTime(CTime::ETimeZone tz=CTime::eLocal) const
void GetDate(string *label, const string &format) const
Append a custom string representation of the date to the label.
EPrecision
for conversion from CTime
ECompare
How *this relates to another date.
@ eCompare_before
*this comes first.
@ eCompare_same
They're equivalent.
@ eCompare_after
*this comes second.
@ eCompare_unknown
Comparison is impossible.
static unsigned char depth[2 *(256+1+29)+1]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
int Minute(void) const
Get minute.
ETimeZone
Which initial value to use for timezone.
int Year(void) const
Get year.
int Day(void) const
Get day.
int Hour(void) const
Get hour.
int Second(void) const
Get second.
int Month(void) const
Get month.
static const char label[]
TMinute GetMinute(void) const
Get the Minute member data.
TMinute & SetMinute(void)
Assign a value to Minute data member.
TSecond GetSecond(void) const
Get the Second member data.
TMonth & SetMonth(void)
Assign a value to Month data member.
const TSeason & GetSeason(void) const
Get the Season member data.
THour GetHour(void) const
Get the Hour member data.
bool CanGetHour(void) const
Check if it is safe to call GetHour method.
bool CanGetDay(void) const
Check if it is safe to call GetDay method.
bool CanGetSecond(void) const
Check if it is safe to call GetSecond method.
bool CanGetSeason(void) const
Check if it is safe to call GetSeason method.
bool CanGetMinute(void) const
Check if it is safe to call GetMinute method.
TYear & SetYear(void)
Assign a value to Year data member.
TYear GetYear(void) const
Get the Year member data.
TMonth GetMonth(void) const
Get the Month member data.
TDay & SetDay(void)
Assign a value to Day data member.
TDay GetDay(void) const
Get the Day member data.
TSecond & SetSecond(void)
Assign a value to Second data member.
THour & SetHour(void)
Assign a value to Hour data member.
bool CanGetMonth(void) const
Check if it is safe to call GetMonth method.
const GenericPointer< typename T::ValueType > T2 value