1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
void displayDate(const Date& date, ostream& os, DATE_STYLE ds)
{
// if ds == MM_DD_YYYY)
if (!wellFormed(date))
{
cout << "Date Error\n";
exit(1);
}
else
if (ds == MM_DD_YYYY)
{
if (numDigits(date) == 7)
os << '0';
os << month(date) << '/';
if (nthDigit(date, 5) == 0)
os << '0';
os << day(date) << '/';
unsigned y = year(date);
unsigned len = 4 - numDigits(y);
for (unsigned i = 0; i < len; ++1)
os << '0';
os << year(date) << endl;
}
else
string Mon[12] = {"Jan ", "Feb ", "Mar ", "Apr ", "May ", "June ", "Jul ", "Aug ",
"Sept ", "Oct ", "Nov ", "Dec " };
os << Mon[month(date) - 1];
if (nthDigit(date, 5) == 0)
os << '0';
os << day(date) << ",";
unsigned y = year(date);
unsigned len = 4 - numDigits(y);
for (unsigned i = 0; i < len; ++1)
os << '0';
os << year(date) << endl;
// }
}
|