summaryrefslogtreecommitdiff
path: root/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-23 04:42:44 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:30 -0400
commit6853db57e6fdb6fd95764be1f35af0006c9e2ef9 (patch)
treebf24550cbc6053c51bf2f3fdcf27f39a4c989f24 /times.cc
parentbe9f18ccfe81acdd2f34b27352f2843235fab69b (diff)
downloadfork-ledger-6853db57e6fdb6fd95764be1f35af0006c9e2ef9.tar.gz
fork-ledger-6853db57e6fdb6fd95764be1f35af0006c9e2ef9.tar.bz2
fork-ledger-6853db57e6fdb6fd95764be1f35af0006c9e2ef9.zip
All tests now working again. Reduced size of entity_t and
transaction_t considerably.
Diffstat (limited to 'times.cc')
-rw-r--r--times.cc25
1 files changed, 9 insertions, 16 deletions
diff --git a/times.cc b/times.cc
index b5ff92ec..43c6f891 100644
--- a/times.cc
+++ b/times.cc
@@ -18,7 +18,7 @@ moment_t& now(date_now);
bool day_before_month = false;
static bool day_before_month_initialized = false;
-moment_t parse_datetime(std::istream& in)
+moment_t parse_datetime(const char * str)
{
if (! day_before_month_initialized) {
#ifdef HAVE_NL_LANGINFO
@@ -31,23 +31,16 @@ moment_t parse_datetime(std::istream& in)
#if 0
return parse_abs_datetime(in);
#else
- string word;
+ int year = ((str[0] - '0') * 1000 +
+ (str[1] - '0') * 100 +
+ (str[2] - '0') * 10 +
+ (str[3] - '0'));
- if (! in.good() || in.eof())
- return moment_t();
+ int mon = ((str[5] - '0') * 10 +
+ (str[6] - '0'));
- in >> word;
-
- int year = ((word[0] - '0') * 1000 +
- (word[1] - '0') * 100 +
- (word[2] - '0') * 10 +
- (word[3] - '0'));
-
- int mon = ((word[5] - '0') * 10 +
- (word[6] - '0'));
-
- int day = ((word[8] - '0') * 10 +
- (word[9] - '0'));
+ int day = ((str[8] - '0') * 10 +
+ (str[9] - '0'));
return moment_t(boost::gregorian::date(year, mon, day));
#endif