We now compile with boost_date_time (although parts of the code have

been stubbed out as a result).
This commit is contained in:
John Wiegley 2007-04-19 00:00:49 +00:00
parent ba2a54f3d2
commit 086ea40d99
25 changed files with 691 additions and 178 deletions

275
Doxyfile Normal file
View file

@ -0,0 +1,275 @@
# Doxyfile 1.5.1
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = Ledger
PROJECT_NUMBER = 3.0
OUTPUT_DIRECTORY = %distdir%/docs
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = /Applications/Copied/
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = %srcdir%
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM \
*.PY
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH = /Applications/Copied/Doxygen.app/Contents/Resources/
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

View file

@ -1,9 +1,18 @@
SUBDIRS = gdtoa
ESC_srcdir=`echo "$(srcdir)" | sed 's/\//\\\\\//g'`
ESC_builddir=`echo "$(top_builddir)" | sed 's/\//\\\\\//g'`
ESC_distdir=`echo "$(distdir)" | sed 's/\//\\\\\//g'`
EXTRA_DIST = docs tests
dist-hook:
rm -fr `find $(distdir) -name .svn`
cat $(srcdir)/Doxyfile | sed "s/%srcdir%/$(ESC_srcdir)/g" \
| sed "s/%distdir%/$(ESC_distdir)/g" > $(distdir)/Doxyfile
doxygen $(distdir)/Doxyfile
lib_LTLIBRARIES = libledger.la
if HAVE_BOOST_PYTHON
@ -140,8 +149,8 @@ info_TEXINFOS = ledger.texi
######################################################################
#lisp_LISP = ledger.el timeclock.el
#dist_lisp_LISP = ledger.el timeclock.el
lisp_LISP = ledger.el timeclock.el
dist_lisp_LISP = ledger.el timeclock.el
######################################################################
@ -170,18 +179,20 @@ DEBUG_LEVEL = 0
endif
ledger.so: pyledger.cc libledger.la gdtoa/libgdtoa.la libpyledger.la
SRCDIR="$(srcdir)" \
CFLAGS="$(CPPFLAGS)" \
LDFLAGS="$(LDFLAGS) -L. -L.libs -Lgdtoa -Lgdtoa/.libs" \
PYLIBS="$(PYLIBS)" \
DEBUG_LEVEL="$(DEBUG_LEVEL)" \
python setup.py build --build-lib=.
python $(srcdir)/setup.py build --build-lib=.
install-exec-hook:
SRCDIR="$(srcdir)" \
CFLAGS="$(CPPFLAGS)" \
LDFLAGS="$(LDFLAGS) -L. -L.libs -Lgdtoa -Lgdtoa/.libs" \
PYLIBS="$(PYLIBS)" \
DEBUG_LEVEL="$(DEBUG_LEVEL)" \
python setup.py install --prefix=$(prefix)
python $(srcdir)/setup.py install --prefix=$(prefix)
endif
@ -220,13 +231,17 @@ endif
PyUnitTests_SOURCES =
PyUnitTests: PyUnitTests.py
cp PyUnitTests.py PyUnitTests
cat $(srcdir)/PyUnitTests.py | sed "s/%srcdir%/$(ESC_srcdir)/g" \
| sed "s/%builddir%/$(ESC_builddir)/g" > PyUnitTests
chmod 755 PyUnitTests
######################################################################
all: check
docs: ledger.info ledger.pdf
doxygen
check-syntax:
g++ -I. -Itests $(CPPFLAGS) $(UnitTests_CXXFLAGS) \
-o /dev/null -S $(CHK_SOURCES)

View file

@ -16,6 +16,7 @@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -64,11 +65,12 @@ check_PROGRAMS = $(am__EXEEXT_2)
@HAVE_LIBOFX_TRUE@am__append_24 = -DHAVE_LIBOFX=1
@DEBUG_TRUE@am__append_25 = -DDEBUG_LEVEL=4
subdir = .
DIST_COMMON = README $(am__configure_deps) $(pkginclude_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/acconf.h.in $(top_srcdir)/configure AUTHORS COPYING \
ChangeLog INSTALL NEWS compile config.guess config.sub depcomp \
install-sh ltmain.sh missing texinfo.tex
DIST_COMMON = README $(am__configure_deps) $(dist_lisp_LISP) \
$(pkginclude_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/acconf.h.in \
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
compile config.guess config.sub depcomp elisp-comp install-sh \
ltmain.sh missing texinfo.tex
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -85,7 +87,8 @@ am__vpath_adj = case $$p in \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(infodir)" "$(DESTDIR)$(pkgincludedir)"
"$(DESTDIR)$(infodir)" "$(DESTDIR)$(lispdir)" \
"$(DESTDIR)$(lispdir)" "$(DESTDIR)$(pkgincludedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libledger_la_LIBADD =
@ -199,6 +202,13 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
dist_lispLISP_INSTALL = $(INSTALL_DATA)
lispLISP_INSTALL = $(INSTALL_DATA)
LISP = $(dist_lisp_LISP) $(lisp_LISP)
am__ELFILES = ledger.el timeclock.el
am__ELCFILES = $(am__ELFILES:.el=.elc)
ELCFILES = $(LISP:.el=.elc)
elisp_comp = $(top_srcdir)/elisp-comp
pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(pkginclude_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
@ -398,6 +408,10 @@ ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la \
$(am__append_16)
ledger_LDFLAGS = -static # for the sake of command-line speed
info_TEXINFOS = ledger.texi
######################################################################
lisp_LISP = ledger.el timeclock.el
dist_lisp_LISP = ledger.el timeclock.el
@HAVE_BOOST_PYTHON_TRUE@ledger_so_SOURCES = pyledger.cc
@HAVE_BOOST_PYTHON_TRUE@PYLIBS = pyledger ledger gdtoa boost_date_time \
@HAVE_BOOST_PYTHON_TRUE@ boost_python gmp pcre $(am__append_18) \
@ -415,6 +429,8 @@ UnitTests_LDFLAGS = $(LIBADD_DL)
UnitTests_CXXFLAGS = -I. -I$(srcdir)/tests $(am__append_22) \
$(am__append_23) $(am__append_24) $(am__append_25)
PyUnitTests_SOURCES =
ESC_srcdir = `echo "$(srcdir)" | sed 's/\//\\\\\//g'`
ESC_builddir = `echo "$(top_builddir)" | sed 's/\//\\\\\//g'`
all: acconf.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@ -1051,6 +1067,85 @@ maintainer-clean-aminfo:
echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
done
elc-stamp: $(LISP)
@echo 'WARNING: Warnings can be ignored. :-)'
@rm -f elc-temp && touch elc-temp
if test "$(EMACS)" != no; then \
set x; \
list='$(LISP)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
set x "$$@" "$$d$$p"; shift; \
done; \
shift; \
EMACS="$(EMACS)" $(SHELL) $(elisp_comp) "$$@" || exit 1; \
else : ; fi
@mv -f elc-temp $@
$(am__ELCFILES): elc-stamp
@if test "$(EMACS)" != no && test ! -f $@; then \
trap 'rm -rf elc-lock elc-stamp' 1 2 13 15; \
if mkdir elc-lock 2>/dev/null; then \
rm -f elc-stamp; \
$(MAKE) $(AM_MAKEFLAGS) elc-stamp; \
rmdir elc-lock; \
else \
while test -d elc-lock; do sleep 1; done; \
test -f elc-stamp; exit $$?; \
fi; \
else : ; fi
install-dist_lispLISP: $(dist_lisp_LISP) $(ELCFILES)
@$(NORMAL_INSTALL)
@if test "$(EMACS)" != no; then \
test -z "$(lispdir)" || $(MKDIR_P) "$(DESTDIR)$(lispdir)"; \
list='$(dist_lisp_LISP)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(dist_lispLISP_INSTALL) '$$d$$p' '$(DESTDIR)$(lispdir)/$$f'"; \
$(dist_lispLISP_INSTALL) "$$d$$p" "$(DESTDIR)$(lispdir)/$$f"; \
if test -f $${p}c; then \
echo " $(dist_lispLISP_INSTALL) '$${p}c' '$(DESTDIR)$(lispdir)/$${f}c'"; \
$(dist_lispLISP_INSTALL) "$${p}c" "$(DESTDIR)$(lispdir)/$${f}c"; \
else : ; fi; \
done; \
else : ; fi
uninstall-dist_lispLISP:
@$(NORMAL_UNINSTALL)
@if test "$(EMACS)" != no; then \
list='$(dist_lisp_LISP)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(lispdir)/$$f' '$(DESTDIR)$(lispdir)/$${f}c'"; \
rm -f "$(DESTDIR)$(lispdir)/$$f" "$(DESTDIR)$(lispdir)/$${f}c"; \
done; \
else : ; fi
clean-lisp:
-rm -f elc-stamp $(ELCFILES)
install-lispLISP: $(lisp_LISP) $(ELCFILES)
@$(NORMAL_INSTALL)
@if test "$(EMACS)" != no; then \
test -z "$(lispdir)" || $(MKDIR_P) "$(DESTDIR)$(lispdir)"; \
list='$(lisp_LISP)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(lispLISP_INSTALL) '$$d$$p' '$(DESTDIR)$(lispdir)/$$f'"; \
$(lispLISP_INSTALL) "$$d$$p" "$(DESTDIR)$(lispdir)/$$f"; \
if test -f $${p}c; then \
echo " $(lispLISP_INSTALL) '$${p}c' '$(DESTDIR)$(lispdir)/$${f}c'"; \
$(lispLISP_INSTALL) "$${p}c" "$(DESTDIR)$(lispdir)/$${f}c"; \
else : ; fi; \
done; \
else : ; fi
uninstall-lispLISP:
@$(NORMAL_UNINSTALL)
@if test "$(EMACS)" != no; then \
list='$(lisp_LISP)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(lispdir)/$$f' '$(DESTDIR)$(lispdir)/$${f}c'"; \
rm -f "$(DESTDIR)$(lispdir)/$$f" "$(DESTDIR)$(lispdir)/$${f}c"; \
done; \
else : ; fi
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
@ -1422,13 +1517,13 @@ check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-recursive
all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) \
acconf.h
all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) $(PROGRAMS) $(LISP) \
$(ELCFILES) $(HEADERS) acconf.h
install-binPROGRAMS: install-libLTLIBRARIES
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(pkgincludedir)"; do \
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(lispdir)" "$(DESTDIR)$(lispdir)" "$(DESTDIR)$(pkgincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
@ -1459,8 +1554,8 @@ maintainer-clean-generic:
clean: clean-recursive
clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
clean-libLTLIBRARIES clean-libtool clean-lisp \
clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
@ -1481,7 +1576,8 @@ info: info-recursive
info-am: $(INFO_DEPS)
install-data-am: install-info-am install-pkgincludeHEADERS
install-data-am: install-dist_lispLISP install-info-am \
install-lispLISP install-pkgincludeHEADERS
install-dvi: install-dvi-recursive
@ -1595,8 +1691,9 @@ ps: ps-recursive
ps-am: $(PSS)
uninstall-am: uninstall-binPROGRAMS uninstall-dvi-am uninstall-html-am \
uninstall-info-am uninstall-libLTLIBRARIES uninstall-pdf-am \
uninstall-am: uninstall-binPROGRAMS uninstall-dist_lispLISP \
uninstall-dvi-am uninstall-html-am uninstall-info-am \
uninstall-libLTLIBRARIES uninstall-lispLISP uninstall-pdf-am \
uninstall-pkgincludeHEADERS uninstall-ps-am
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
@ -1605,25 +1702,27 @@ uninstall-am: uninstall-binPROGRAMS uninstall-dvi-am uninstall-html-am \
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-TESTS check-am clean \
clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \
dist-info dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-binPROGRAMS install-data \
install-data-am install-dvi install-dvi-am install-exec \
clean-libLTLIBRARIES clean-libtool clean-lisp \
clean-noinstPROGRAMS ctags ctags-recursive dist dist-all \
dist-bzip2 dist-gzip dist-hook dist-info dist-shar dist-tarZ \
dist-zip distcheck distclean distclean-compile \
distclean-generic distclean-hdr distclean-libtool \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am \
install-dist_lispLISP install-dvi install-dvi-am install-exec \
install-exec-am install-exec-hook install-html install-html-am \
install-info install-info-am install-libLTLIBRARIES \
install-man install-pdf install-pdf-am \
install-lispLISP install-man install-pdf install-pdf-am \
install-pkgincludeHEADERS install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-aminfo \
maintainer-clean-generic mostlyclean mostlyclean-aminfo \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-binPROGRAMS uninstall-dvi-am uninstall-html-am \
uninstall-info-am uninstall-libLTLIBRARIES uninstall-pdf-am \
uninstall-binPROGRAMS uninstall-dist_lispLISP uninstall-dvi-am \
uninstall-html-am uninstall-info-am uninstall-libLTLIBRARIES \
uninstall-lispLISP uninstall-pdf-am \
uninstall-pkgincludeHEADERS uninstall-ps-am
@ -1631,27 +1730,33 @@ dist-hook:
rm -fr `find $(distdir) -name .svn`
@HAVE_BOOST_PYTHON_TRUE@ledger.so: pyledger.cc libledger.la gdtoa/libgdtoa.la libpyledger.la
@HAVE_BOOST_PYTHON_TRUE@ SRCDIR="$(srcdir)" \
@HAVE_BOOST_PYTHON_TRUE@ CFLAGS="$(CPPFLAGS)" \
@HAVE_BOOST_PYTHON_TRUE@ LDFLAGS="$(LDFLAGS) -L. -L.libs -Lgdtoa -Lgdtoa/.libs" \
@HAVE_BOOST_PYTHON_TRUE@ PYLIBS="$(PYLIBS)" \
@HAVE_BOOST_PYTHON_TRUE@ DEBUG_LEVEL="$(DEBUG_LEVEL)" \
@HAVE_BOOST_PYTHON_TRUE@ python setup.py build --build-lib=.
@HAVE_BOOST_PYTHON_TRUE@ python $(srcdir)/setup.py build --build-lib=.
@HAVE_BOOST_PYTHON_TRUE@install-exec-hook:
@HAVE_BOOST_PYTHON_TRUE@ SRCDIR="$(srcdir)" \
@HAVE_BOOST_PYTHON_TRUE@ CFLAGS="$(CPPFLAGS)" \
@HAVE_BOOST_PYTHON_TRUE@ LDFLAGS="$(LDFLAGS) -L. -L.libs -Lgdtoa -Lgdtoa/.libs" \
@HAVE_BOOST_PYTHON_TRUE@ PYLIBS="$(PYLIBS)" \
@HAVE_BOOST_PYTHON_TRUE@ DEBUG_LEVEL="$(DEBUG_LEVEL)" \
@HAVE_BOOST_PYTHON_TRUE@ python setup.py install --prefix=$(prefix)
@HAVE_BOOST_PYTHON_TRUE@ python $(srcdir)/setup.py install --prefix=$(prefix)
PyUnitTests: PyUnitTests.py
cp PyUnitTests.py PyUnitTests
cat $(srcdir)/PyUnitTests.py | sed "s/%srcdir%/$(ESC_srcdir)/g" \
| sed "s/%builddir%/$(ESC_builddir)/g" > PyUnitTests
chmod 755 PyUnitTests
######################################################################
all: check
docs: ledger.info ledger.pdf
doxygen
check-syntax:
g++ -I. -Itests $(CPPFLAGS) $(UnitTests_CXXFLAGS) \
-o /dev/null -S $(CHK_SOURCES)

View file

@ -1,3 +1,4 @@
#!/bin/sh
PYTHONPATH=$PWD:$PYTHONPATH python tests/python/UnitTests.py
PYTHONPATH="%builddir%":"%srcdir%":$PYTHONPATH \
python "%srcdir%"/tests/python/UnitTests.py

103
acprep
View file

@ -1,31 +1,38 @@
#!/bin/sh
PYTHON_HOME="/Library/Frameworks/Python.framework/Versions/2.5"
# acprep, version 3.0
#
# This script configures my ledger source tree on my Mac OS/X machine.
# This is not necessary, however, since I keep all the files necessary
# for building checked in to the source tree. Users can just type
# './configure && make'. This script simply sets up the compiler and
# linker flags for all the various build permutations I use for
# testing and profiling.
if which glibtoolize > /dev/null 2>&1; then
glibtoolize --automake -f -c
else
libtoolize --automake -f -c
fi
aclocal
autoheader
if [ "$1" = "--dist" ]; then
shift 1
automake -a -c -f -i
else
automake -a -c -f
fi
automake -a -c -f
autoconf
INCDIRS="-I/usr/local/include"
INCDIRS="$INCDIRS -I/usr/local/include/boost"
INCDIRS="$INCDIRS -I/sw/include"
INCDIRS="$INCDIRS -I/usr/include/httpd/xml"
INCDIRS="$INCDIRS -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5"
LIBDIRS="-L/usr/local/lib"
LIBDIRS="$LIBDIRS -L/sw/lib"
LIBDIRS="$LIBDIRS -L/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config"
SYSTEM=`uname -s`
if [ $SYSTEM = Linux ]; then
CXXFLAGS="-pthread"
elif [ $SYSTEM = Solaris ]; then
@ -49,45 +56,47 @@ WARNFLAGS="$WARNFLAGS -pedantic-errors"
# that is built again anyway by Xcode).
SWITCHES="--disable-shared"
while [ -n "$1" ]; do
case "$1" in
--debug)
SWITCHES="$SWITCHES --enable-debug"
CXXFLAGS="$CXXFLAGS -ggdb3" ;;
--prof | --perf)
CXXFLAGS="$CXXFLAGS -g -pg" ;;
--python)
if [ -d "$PYTHON_HOME" ]; then
SWITCHES="$SWITCHES --enable-python"
INCDIRS="$INCDIRS -I$PYTHON_HOME/include/python2.5"
LIBDIRS="$LIBDIRS -L$PYTHON_HOME/lib/python2.5/config"
fi ;;
--opt)
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3 -fPIC" ;;
--flat-opt)
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3" ;;
--safe-opt)
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3 -fPIC -DDEBUG_LEVEL=1" ;;
*)
break ;;
esac
shift 1
done
HERE="$PWD"
#if [ -d "$HOME/Products" ]; then
# projdir="$HOME/Products/$(basename $HERE)"
# if [ ! -d "$projdir" ]; then
# mkdir -p "$projdir"
# fi
# cd "$projdir" || (echo "Cannot change to $projdir"; exit 1)
#fi
if [ "$1" = "--debug" ]; then
shift 1
"$HERE/configure" --srcdir="$HERE" \
CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" CXXFLAGS="$CXXFLAGS -ggdb3" \
WARNFLAGS="$WARNFLAGS" $SWITCHES --enable-debug "$@"
elif [ "$1" = "--python-debug" -o "$1" = "--debug-python" ]; then
shift 1
"$HERE/configure" --srcdir="$HERE" \
CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" CXXFLAGS="$CXXFLAGS -ggdb3" \
WARNFLAGS="$WARNFLAGS" $SWITCHES --enable-debug --enable-python "$@"
elif [ "$1" = "--opt" ]; then
shift 1
"$HERE/configure" --srcdir="$HERE" \
CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" WARNFLAGS="$WARNFLAGS" \
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3 -fPIC" "$@" $SWITCHES
elif [ "$1" = "--flat-opt" ]; then
shift 1
"$HERE/configure" --srcdir="$HERE" \
CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" WARNFLAGS="$WARNFLAGS" \
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3" "$@" $SWITCHES
elif [ "$1" = "--safe-opt" ]; then
shift 1
"$HERE/configure" --srcdir="$HERE" \
CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" WARNFLAGS="$WARNFLAGS" \
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3 -fPIC -DDEBUG_LEVEL=1" "$@" \
$SWITCHES
elif [ "$1" = "--perf" ]; then
shift 1
"$HERE/configure" --srcdir="$HERE" WARNFLAGS="$WARNFLAGS" \
CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \
CXXFLAGS="$CXXFLAGS -ggdb3 -pg" "$@" $SWITCHES
if [ -d "$HOME/Products" ]; then
projdir="$HOME/Products/$(basename $HERE)"
if [ ! -d "$projdir" ]; then
mkdir -p "$projdir"
fi
cd "$projdir" || (echo "Cannot change to $projdir"; exit 1)
fi
"$HERE/configure" --srcdir="$HERE" CPPFLAGS="$INCDIRS" \
CXXFLAGS="$CXXFLAGS $local_cxxflags" WARNFLAGS="$WARNFLAGS" \
LDFLAGS="$LIBDIRS" $SWITCHES "$@"

View file

@ -52,6 +52,19 @@ extern bool do_cleanup;
class commodity_t;
/** @class amount_t
@brief Encapsulates infinite precision commoditized amounts.
The amount_t class can be used for commoditized infinite precision
math, and also for uncommoditized math. In the commoditized case,
commodities will keep track of how they are used, so that they
always display back to the user in the same fashion as their use.
However, in all cases precision is kept to an excessive degree
internally. For uncommoditized numbers, no display truncation is
ever done.
*/
class amount_t
{
public:

View file

@ -1,2 +0,0 @@
#define IEEE_8087
#define Arith_Kind_ASL 1

View file

@ -235,7 +235,7 @@ void dataHandler(void *userData, const char *s, int len)
break;
case gnucash_parser_t::ENTRY_DATE:
parser->curr_entry->_date = std::string(s, len);
parser->curr_entry->_date = ptime_from_local_date_string(std::string(s, len));
break;
case gnucash_parser_t::ENTRY_DESC:

View file

@ -24,14 +24,14 @@ transaction_t::~transaction_t()
ptime transaction_t::actual_date() const
{
if (! _date && entry)
if (_date.is_not_a_date_time() && entry)
return entry->actual_date();
return _date;
}
ptime transaction_t::effective_date() const
{
if (! _date_eff && entry)
if (_date_eff.is_not_a_date_time() && entry)
return entry->effective_date();
return _date_eff;
}
@ -312,7 +312,7 @@ void entry_t::add_transaction(transaction_t * xact)
bool entry_t::valid() const
{
if (! _date || ! journal) {
if (_date.is_not_a_date_time() || ! journal) {
DEBUG_PRINT("ledger.validate", "entry_t: ! _date || ! journal");
return false;
}

BIN
ledger.pdf Normal file

Binary file not shown.

View file

@ -64,7 +64,6 @@ void export_amount()
.def(init<amount_t>())
.def(init<std::string>())
.def(init<char *>())
.def(init<bool>())
.def(init<long>())
.def(init<double>())

2
qif.cc
View file

@ -102,7 +102,7 @@ unsigned int qif_parser_t::parse(std::istream& in,
case 'D':
SET_BEG_POS_AND_LINE();
get_line(in);
entry->_date = line;
entry->_date = ptime_from_local_date_string(line);
break;
case 'T':

View file

@ -49,10 +49,13 @@ void report_t::ftime(value_t& result, xml::xpath_t::scope_t * locals)
std::string date_format;
if (locals->args.size() == 2)
date_format = locals->args[1].to_string();
#if 0
// jww (2007-04-18): Need to setup an output facet here
else
date_format = ptime::output_format;
result.set_string(date.to_string(date_format));
#endif
}
bool report_t::resolve(const std::string& name, value_t& result,

View file

@ -136,7 +136,10 @@ bool session_t::resolve(const std::string& name, value_t& result,
switch (*p) {
case 'd':
if (name == "date_format") {
// jww (2007-04-18): What to do here?
#if 0
result.set_string(ptime::output_format);
#endif
return true;
}
break;

View file

@ -18,5 +18,5 @@ setup(name = "Ledger",
author_email = "johnw@newartisans.com",
url = "http://johnwiegley.com/",
ext_modules = [
Extension("ledger", ["pyledger.cc"],
Extension("ledger", [os.path.join(os.environ['SRCDIR'], "pyledger.cc")],
define_macros = defines, libraries = libs)])

View file

@ -14,7 +14,6 @@ void BasicAmountTestCase::testConstructors()
amount_t x1(123456L);
amount_t x2(123456UL);
amount_t x3(123.456);
amount_t x4(true);
amount_t x5("123456");
amount_t x6("123.456");
amount_t x7(std::string("123456"));
@ -33,14 +32,12 @@ void BasicAmountTestCase::testConstructors()
assertEqual(x6, x3);
assertEqual(x8, x3);
assertEqual(x10, x3);
assertEqual(amount_t(1L), x4);
assertEqual(x10, x9);
CPPUNIT_ASSERT(x0.valid());
CPPUNIT_ASSERT(x1.valid());
CPPUNIT_ASSERT(x2.valid());
CPPUNIT_ASSERT(x3.valid());
CPPUNIT_ASSERT(x4.valid());
CPPUNIT_ASSERT(x5.valid());
CPPUNIT_ASSERT(x6.valid());
CPPUNIT_ASSERT(x7.valid());
@ -91,7 +88,6 @@ void BasicAmountTestCase::testAssignment()
amount_t x1 = 123456L;
amount_t x2 = 123456UL;
amount_t x3 = 123.456;
amount_t x4 = true;
amount_t x5 = "123456";
amount_t x6 = "123.456";
amount_t x7 = std::string("123456");
@ -106,14 +102,12 @@ void BasicAmountTestCase::testAssignment()
assertEqual(x6, x3);
assertEqual(x8, x3);
assertEqual(x10, x3);
assertEqual(amount_t(1L), x4);
assertEqual(x10, x9);
x0 = amount_t();
x1 = 123456L;
x2 = 123456UL;
x3 = 123.456;
x4 = true;
x5 = "123456";
x6 = "123.456";
x7 = std::string("123456");
@ -128,14 +122,12 @@ void BasicAmountTestCase::testAssignment()
assertEqual(x6, x3);
assertEqual(x8, x3);
assertEqual(x10, x3);
assertEqual(amount_t(1L), x4);
assertEqual(x10, x9);
CPPUNIT_ASSERT(x0.valid());
CPPUNIT_ASSERT(x1.valid());
CPPUNIT_ASSERT(x2.valid());
CPPUNIT_ASSERT(x3.valid());
CPPUNIT_ASSERT(x4.valid());
CPPUNIT_ASSERT(x5.valid());
CPPUNIT_ASSERT(x6.valid());
CPPUNIT_ASSERT(x7.valid());
@ -182,20 +174,12 @@ void BasicAmountTestCase::testIntegerAddition()
x1 += 456L;
assertEqual(amount_t(1035L), x1);
amount_t x3(true);
amount_t y3(true);
assertEqual(amount_t(2L), x3 + y3);
assertEqual(amount_t(2L), x3 + true);
amount_t x4("123456789123456789123456789");
assertEqual(amount_t("246913578246913578246913578"), x4 + x4);
CPPUNIT_ASSERT(x1.valid());
CPPUNIT_ASSERT(y1.valid());
CPPUNIT_ASSERT(x3.valid());
CPPUNIT_ASSERT(y3.valid());
CPPUNIT_ASSERT(x4.valid());
}
@ -239,11 +223,6 @@ void BasicAmountTestCase::testIntegerSubtraction()
x1 -= 456L;
assertEqual(amount_t(-789L), x1);
amount_t x3(true);
amount_t y3(true);
assertEqual(amount_t(false), x3 - y3);
amount_t x4("123456789123456789123456789");
amount_t y4("8238725986235986");
@ -252,8 +231,6 @@ void BasicAmountTestCase::testIntegerSubtraction()
CPPUNIT_ASSERT(x1.valid());
CPPUNIT_ASSERT(y1.valid());
CPPUNIT_ASSERT(x3.valid());
CPPUNIT_ASSERT(y3.valid());
CPPUNIT_ASSERT(x4.valid());
CPPUNIT_ASSERT(y4.valid());
}
@ -310,11 +287,6 @@ void BasicAmountTestCase::testIntegerMultiplication()
x1 *= 123L;
assertEqual(amount_t(1860867L), x1);
amount_t x3(true);
amount_t y3(true);
assertEqual(amount_t(true), x3 * y3);
amount_t x4("123456789123456789123456789");
assertEqual(amount_t("15241578780673678546105778281054720515622620750190521"),
@ -322,8 +294,6 @@ void BasicAmountTestCase::testIntegerMultiplication()
CPPUNIT_ASSERT(x1.valid());
CPPUNIT_ASSERT(y1.valid());
CPPUNIT_ASSERT(x3.valid());
CPPUNIT_ASSERT(y3.valid());
CPPUNIT_ASSERT(x4.valid());
}

View file

@ -15,12 +15,12 @@ void CommodityTestCase::testConstructors()
void CommodityTestCase::testPriceHistory()
{
datetime_t jan17_07("2007/01/17 00:00:00");
datetime_t feb27_07("2007/02/27 18:00:00");
datetime_t feb28_07("2007/02/28 06:00:00");
datetime_t feb28_07sbm("2007/02/28 11:59:59");
datetime_t mar01_07("2007/03/01 00:00:00");
datetime_t apr15_07("2007/04/15 13:00:00");
ptime jan17_07 = boost::posix_time::time_from_string("2007/01/17 00:00:00");
ptime feb27_07 = boost::posix_time::time_from_string("2007/02/27 18:00:00");
ptime feb28_07 = boost::posix_time::time_from_string("2007/02/28 06:00:00");
ptime feb28_07sbm = boost::posix_time::time_from_string("2007/02/28 11:59:59");
ptime mar01_07 = boost::posix_time::time_from_string("2007/03/01 00:00:00");
ptime apr15_07 = boost::posix_time::time_from_string("2007/04/15 13:00:00");
// jww (2007-04-17): tbd
amount_t x1("100.10 AAPL");
@ -29,9 +29,9 @@ void CommodityTestCase::testPriceHistory()
// deal of their state depends on how they were seen to be used.
commodity_t& aapl(x1.commodity());
aapl.add_price(datetime_t(), amount_t("$10.20"));
aapl.add_price(now, amount_t("$10.20"));
assertEqual(amount_t("$1021.02"), x1.value(datetime_t()));
assertEqual(amount_t("$1021.02"), x1.value(now));
assertValid(x1);
}

View file

@ -0,0 +1,101 @@
#include "DateTimeTest.h"
#include "ledger.h"
#include "acconf.h"
#include <ctime>
using namespace ledger;
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(DateTimeTestCase, "numerics");
void DateTimeTestCase::setUp() {}
void DateTimeTestCase::tearDown() {}
void DateTimeTestCase::testConstructors()
{
struct tm moment;
std::memset(&moment, INT_MAX, sizeof(struct tm));
#ifdef HAVE_STRPTIME
strptime("2006/12/25 00:00:00", "%Y/%m/%d %H:%M:%S", &moment);
#endif
#ifdef HAVE_TIMEGM
std::time_t gmtMoment = timegm(&moment);
#endif
std::time_t localMoment = std::mktime(&moment);
date_t d1;
#ifdef HAVE_TIMEGM
date_t d2(gmtMoment);
#endif
date_t d3(localMoment);
date_t d4("2006/12/25");
date_t d5("12/25");
date_t d6("2006.12.25");
date_t d7("12.25");
date_t d8("2006-12-25");
date_t d9("12-25");
date_t d10("tue");
date_t d11("tuesday");
date_t d12("feb");
date_t d13("february");
date_t d14("2006");
date_t d15(d3);
#ifdef HAVE_TIMEGM
if (std::memcmp(&gmtMoment, &localMoment, sizeof(std::time_t)) == 0)
assertEqual(d2, d3);
else
assertNotEqual(d2, d3);
#endif
assertFalse(d1);
assertTrue(d4);
assertTrue(date_t::now > d1);
assertTrue(date_t::now > d3);
assertTrue(date_t::now > d4);
assertEqual(d3, d4);
assertEqual(d3, d15);
assertEqual(d4, d6);
assertEqual(d4, d8);
assertEqual(d5, d7);
assertEqual(d5, d9);
assertEqual(d10, d11);
assertEqual(d12, d13);
assertThrow(date_t("2007/02/29"), date_error *);
assertThrow(date_t("2007/13/01"), date_error *);
assertThrow(date_t("2007/00/01"), date_error *);
assertThrow(date_t("2007/01/00"), date_error *);
assertThrow(date_t("2007/00/00"), date_error *);
assertThrow(date_t("2007/05/32"), date_error *);
assertThrow(date_t("2006x/12/25"), date_error *);
assertThrow(date_t("2006/12x/25"), date_error *);
assertThrow(date_t("2006/12/25x"), date_error *);
assertThrow(date_t("feb/12/25"), date_error *);
assertThrow(date_t("2006/mon/25"), date_error *);
assertThrow(date_t("2006/12/web"), date_error *);
assertThrow(date_t("12*25"), date_error *);
assertThrow(date_t("tuf"), date_error *);
assertThrow(date_t("tufsday"), date_error *);
assertThrow(date_t("fec"), date_error *);
assertThrow(date_t("fecruary"), date_error *);
assertThrow(date_t("207x"), date_error *);
assertThrow(date_t("hello"), date_error *);
datetime_t dt1;
datetime_t dt2;
datetime_t dt3;
datetime_t dt4;
datetime_t dt5;
interval_t i1;
interval_t i2;
}

View file

@ -0,0 +1,28 @@
#ifndef _DATETIMETEST_H
#define _DATETIMETEST_H
#include "UnitTests.h"
class DateTimeTestCase : public CPPUNIT_NS::TestCase
{
CPPUNIT_TEST_SUITE(DateTimeTestCase);
CPPUNIT_TEST(testConstructors);
CPPUNIT_TEST_SUITE_END();
public:
DateTimeTestCase() {}
virtual ~DateTimeTestCase() {}
virtual void setUp();
virtual void tearDown();
void testConstructors();
private:
DateTimeTestCase(const DateTimeTestCase &copy);
void operator=(const DateTimeTestCase &copy);
};
#endif /* _DATETIMETEST_H */

View file

@ -9,7 +9,6 @@ class BasicAmountTestCase(unittest.TestCase):
x1 = amount(123456)
x2 = amount(123456L)
x3 = amount(123.456)
x4 = amount(True)
x5 = amount("123456")
x6 = amount("123.456")
x9 = amount(x3)
@ -20,14 +19,12 @@ class BasicAmountTestCase(unittest.TestCase):
self.assertEqual(x5, x1)
self.assertEqual(x6, x3)
self.assertEqual(x10, x3)
self.assertEqual(amount(1), x4)
self.assertEqual(x10, x9)
self.assertTrue(x0.valid())
self.assertTrue(x1.valid())
self.assertTrue(x2.valid())
self.assertTrue(x3.valid())
self.assertTrue(x4.valid())
self.assertTrue(x5.valid())
self.assertTrue(x6.valid())
self.assertTrue(x9.valid())
@ -65,7 +62,6 @@ class BasicAmountTestCase(unittest.TestCase):
x1 = amount(123456)
x2 = amount(123456L)
x3 = amount(123.456)
x4 = amount(True)
x5 = amount("123456")
x6 = amount("123.456")
x9 = x3
@ -76,14 +72,12 @@ class BasicAmountTestCase(unittest.TestCase):
self.assertEqual(x5, x1)
self.assertEqual(x6, x3)
self.assertEqual(x10, x3)
self.assertEqual(amount(1), x4)
self.assertEqual(x10, x9)
x0 = amount()
x1 = amount(123456)
x2 = amount(123456L)
x3 = amount(123.456)
x4 = amount(True)
x5 = amount("123456")
x6 = amount("123.456")
x9 = x3
@ -94,14 +88,12 @@ class BasicAmountTestCase(unittest.TestCase):
self.assertEqual(x5, x1)
self.assertEqual(x6, x3)
self.assertEqual(x10, x3)
self.assertEqual(amount(1), x4)
self.assertEqual(x10, x9)
self.assertTrue(x0.valid())
self.assertTrue(x1.valid())
self.assertTrue(x2.valid())
self.assertTrue(x3.valid())
self.assertTrue(x4.valid())
self.assertTrue(x5.valid())
self.assertTrue(x6.valid())
self.assertTrue(x9.valid())
@ -139,20 +131,12 @@ class BasicAmountTestCase(unittest.TestCase):
x1 += 456
self.assertEqual(amount(1035), x1)
x3 = amount(True)
y3 = amount(True)
self.assertEqual(amount(2), x3 + y3)
self.assertEqual(amount(2), x3 + True)
x4 = amount("123456789123456789123456789")
self.assertEqual(amount("246913578246913578246913578"), x4 + x4)
self.assertTrue(x1.valid())
self.assertTrue(y1.valid())
self.assertTrue(x3.valid())
self.assertTrue(y3.valid())
self.assertTrue(x4.valid())
def testFractionalAddition(self):
@ -192,11 +176,6 @@ class BasicAmountTestCase(unittest.TestCase):
x1 -= 456
self.assertEqual(amount(-789), x1)
x3 = amount(True)
y3 = amount(True)
self.assertEqual(amount(False), x3 - y3)
x4 = amount("123456789123456789123456789")
y4 = amount("8238725986235986")
@ -205,8 +184,6 @@ class BasicAmountTestCase(unittest.TestCase):
self.assertTrue(x1.valid())
self.assertTrue(y1.valid())
self.assertTrue(x3.valid())
self.assertTrue(y3.valid())
self.assertTrue(x4.valid())
self.assertTrue(y4.valid())
@ -259,11 +236,6 @@ class BasicAmountTestCase(unittest.TestCase):
x1 *= 123
self.assertEqual(amount(1860867), x1)
x3 = amount(True)
y3 = amount(True)
self.assertEqual(amount(True), x3 * y3)
x4 = amount("123456789123456789123456789")
self.assertEqual(amount("15241578780673678546105778281054720515622620750190521"),
@ -271,8 +243,6 @@ class BasicAmountTestCase(unittest.TestCase):
self.assertTrue(x1.valid())
self.assertTrue(y1.valid())
self.assertTrue(x3.valid())
self.assertTrue(y3.valid())
self.assertTrue(x4.valid())
def testFractionalMultiplication(self):

View file

@ -276,10 +276,10 @@ transaction_t * parse_transaction(char * line,
if (char * p = std::strchr(buf, '=')) {
*p++ = '\0';
xact->_date_eff = p;
xact->_date_eff = ptime_from_local_date_string(p);
}
if (buf[0])
xact->_date = buf;
xact->_date = ptime_from_local_date_string(buf);
}
}
}
@ -348,11 +348,17 @@ entry_t * parse_entry(std::istream& in, char * line, journal_t * journal,
TIMER_START(entry_date);
#if 0
// jww (2007-04-18): Need to write a full date parser
curr->_date.parse(line_in);
#endif
if (peek_next_nonws(line_in) == '=') {
line_in.get(c);
#if 0
// jww (2007-04-18): Need to write a full date parser
curr->_date_eff.parse(line_in);
#endif
}
TIMER_STOP(entry_date);
@ -492,9 +498,9 @@ bool textual_parser_t::test(std::istream& in) const
}
static void clock_out_from_timelog(const ptime& when,
account_t * account,
const char * desc,
journal_t * journal)
account_t * account,
const char * desc,
journal_t * journal)
{
time_entry_t event;
@ -542,7 +548,7 @@ static void clock_out_from_timelog(const ptime& when,
("Timelog check-out date less than corresponding check-in");
char buf[32];
std::sprintf(buf, "%lds", curr->_date - event.checkin);
std::sprintf(buf, "%lds", (curr->_date - event.checkin).total_seconds());
amount_t amt;
amt.parse(buf);
@ -617,7 +623,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
time_entry_t event;
event.desc = n ? n : "";
event.checkin = date;
event.checkin = ptime_from_local_time_string(date);
event.account = account_stack.front()->find_account(p);
if (! time_entries.empty())
@ -643,8 +649,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
char * n = next_element(p, true);
clock_out_from_timelog
(date, p ? account_stack.front()->find_account(p) : NULL, n,
journal);
(ptime_from_local_time_string(date),
p ? account_stack.front()->find_account(p) : NULL, n, journal);
count++;
}
break;
@ -707,7 +713,10 @@ unsigned int textual_parser_t::parse(std::istream& in,
}
case 'Y': // set current year
#if 0
// jww (2007-04-18): Need to set this up again
date_t::current_year = std::atoi(skip_ws(line + 1));
#endif
break;
#ifdef TIMELOG_SUPPORT

25
times.h
View file

@ -11,16 +11,29 @@
namespace ledger {
using namespace boost::posix_time;
using namespace boost::date_time;
typedef boost::posix_time::ptime ptime;
typedef boost::posix_time::seconds seconds;
typedef ptime::time_duration_type time_duration;
typedef ptime::time_duration_type time_duration;
class interval_t
{
public:
interval_t() {}
interval_t(const std::string& desc) {}
class interval_t {};
operator bool() const {
return false;
}
void start(const ptime& moment) {}
ptime next() const {}
void parse(std::istream& in) {}
};
inline ptime ptime_local_to_utc(const ptime& when) {
struct std::tm tm_gmt = to_tm(when);
return from_time_t(std::mktime(&tm_gmt));
return boost::posix_time::from_time_t(std::mktime(&tm_gmt));
}
// jww (2007-04-18): I need to make a general parsing function
@ -31,7 +44,7 @@ inline ptime ptime_from_local_date_string(const std::string& date_string) {
}
inline ptime ptime_from_local_time_string(const std::string& time_string) {
return ptime_local_to_utc(time_from_string(time_string));
return ptime_local_to_utc(boost::posix_time::time_from_string(time_string));
}
extern ptime now;

View file

@ -1,4 +1,5 @@
#include "trace.h"
#include "times.h"
#include "acconf.h"
namespace ledger {
@ -8,8 +9,8 @@ bool trace_mode;
void trace(const std::string& cat, const std::string& str)
{
char buf[32];
std::cerr << now.to_short_string() << " " << cat << ": " << str
<< std::endl;
std::cerr << boost::posix_time::to_simple_string(now) << " "
<< cat << ": " << str << std::endl;
}
void trace_push(const std::string& cat, const std::string& str,

View file

@ -79,10 +79,10 @@ static void endElement(void *userData, const char *name)
curr_entry = NULL;
}
else if (std::strcmp(name, "en:date") == 0) {
curr_entry->_date = data;
curr_entry->_date = ptime_from_local_date_string(data);
}
else if (std::strcmp(name, "en:date_eff") == 0) {
curr_entry->_date_eff = data;
curr_entry->_date_eff = ptime_from_local_date_string(data);
}
else if (std::strcmp(name, "en:code") == 0) {
curr_entry->code = data;

View file

@ -158,7 +158,7 @@ void xpath_t::token_t::next(std::istream& in, unsigned short flags)
length++;
interval_t timespan(buf);
kind = VALUE;
value = timespan.first();
value = timespan.next();
} else {
kind = LBRACKET;
}