summaryrefslogtreecommitdiff
path: root/datetime.h
blob: 1acf2609ffd184ccfb15b61308d17439b3e1d6f9 (plain)
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
#ifndef _DATETIME_H
#define _DATETIME_H

#include "ledger.h"

namespace ledger {

struct interval_t
{
  unsigned long years;
  unsigned long months;
  unsigned long seconds;

  interval_t(unsigned long _seconds, unsigned long _months = 0,
	     unsigned long _years = 0)
    : years(_years), months(_months), seconds(_seconds) {}

  std::time_t increment(const std::time_t);

  static interval_t * parse(std::istream& in);
};

extern struct std::tm * now_tm;

bool parse_date_mask(const char * date_str, struct std::tm * result);

bool parse_date(const char * date_str, std::time_t * result,
		const int year = -1);

bool quick_parse_date(char * date_str, std::time_t * result);

} // namespace ledger

#endif // _DATETIME_H