diff --git a/CHANGES b/CHANGES
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,17 @@
-User-visible changes in hledger-web.
-See also the hledger and the project change logs.
+User-visible changes in hledger-web. See also hledger, hledger-lib.
+
+
+# 1.5 (2017/12/31)
+
+* add form account fields now suggest implied and declared account names also
+
+* add form date field now uses a datepicker (Eli Flanagan)
+
+* don't write a session file at startup, don't require a writable working directory
+
+* support -V/--value, --forecast, --auto
+
+* remove upper bounds on all but hledger* and base (experimental)
 
 
 # 1.4 (2017/9/30)
diff --git a/Foundation.hs b/Foundation.hs
--- a/Foundation.hs
+++ b/Foundation.hs
@@ -100,11 +100,13 @@
 instance Yesod App where
     approot = ApprootMaster $ appRoot . settings
 
-    -- Store session data on the client in encrypted cookies,
-    -- default session idle timeout is 120 minutes
-    makeSessionBackend _ = fmap Just $ defaultClientSessionBackend
-                             (120 * 60)
-                             ".hledger-web_client_session_key.aes"
+--    -- Store session data on the client in encrypted cookies,
+--    -- default session idle timeout is 120 minutes
+--    makeSessionBackend _ = fmap Just $ defaultClientSessionBackend
+--                             (120 * 60)
+--                             ".hledger-web_client_session_key.aes"
+    -- don't use session data
+    makeSessionBackend _ = return Nothing
 
     defaultLayout widget = do
         master <- getYesod
@@ -125,6 +127,7 @@
 
         pc <- widgetToPageContent $ do
             addStylesheet $ StaticR css_bootstrap_min_css
+            addStylesheet $ StaticR css_bootstrap_datepicker_standalone_min_css
              -- load these things early, in HEAD:
             toWidgetHead [hamlet|
                           <script type="text/javascript" src="@{StaticR js_jquery_min_js}">
@@ -132,6 +135,7 @@
                          |]
             addScript $ StaticR js_bootstrap_min_js
             -- addScript $ StaticR js_typeahead_bundle_min_js
+            addScript $ StaticR js_bootstrap_datepicker_min_js
             addScript $ StaticR js_jquery_url_js
             addScript $ StaticR js_jquery_cookie_js
             addScript $ StaticR js_jquery_hotkeys_js
@@ -297,19 +301,11 @@
 addform :: Text -> ViewData -> HtmlUrl AppRoute
 addform _ vd@VD{..} = [hamlet|
 
-<script language="javascript">
+<script>
   jQuery(document).ready(function() {
 
     /* set up typeahead fields */
 
-    datesSuggester = new Bloodhound({
-      local:#{listToJsonValueObjArrayStr dates},
-      limit:100,
-      datumTokenizer: function(d) { return [d.value]; },
-      queryTokenizer: function(q) { return [q]; }
-    });
-    datesSuggester.initialize();
-
     descriptionsSuggester = new Bloodhound({
       local:#{listToJsonValueObjArrayStr descriptions},
       limit:100,
@@ -331,7 +327,6 @@
     });
     accountsSuggester.initialize();
 
-    enableTypeahead(jQuery('input#date'), datesSuggester);
     enableTypeahead(jQuery('input#description'), descriptionsSuggester);
     enableTypeahead(jQuery('input#account1, input#account2, input#account3, input#account4'), accountsSuggester);
 
@@ -340,10 +335,13 @@
 <form#addform method=POST .form>
  <div .form-group>
   <div .row>
-   <div .col-md-2 .col-xs-6 .col-sm-6>
-    <input #date .typeahead .form-control .input-lg type=text size=15 name=date placeholder="Date" value="#{defdate}">
-   <div .col-md-10 .col-xs-6 .col-sm-6>
-    <input #description .typeahead .form-control .input-lg type=text size=40 name=description placeholder="Description">
+   <div .col-md-3 .col-xs-6 .col-sm-6>
+    <div #dateWrap .input-group .date>
+     <input #date required lang=en name=date .form-control .input-lg placeholder="Date" >
+     <div .input-group-addon>
+      <span .glyphicon .glyphicon-th>
+   <div .col-md-9 .col-xs-6 .col-sm-6>
+    <input #description required .typeahead .form-control .input-lg type=text size=40 name=description placeholder="Description">
  <div .account-postings>
   $forall n <- postingnums
     ^{postingfields vd n}
@@ -361,10 +359,8 @@
     (or ctrl +, ctrl -)
 |]
  where
-  defdate = "" :: String -- #322 don't set a default, typeahead(?) clears it on tab. See also hledger.js
-  dates = ["today","yesterday","tomorrow"] :: [String]
   descriptions = sort $ nub $ map tdescription $ jtxns j
-  accts = sort $ journalAccountNamesUsed j
+  accts = journalAccountNamesDeclaredOrImplied j
   escapeJSSpecialChars = regexReplaceCI "</script>" "<\\/script>" -- #236
   listToJsonValueObjArrayStr as  = preEscapedString $ escapeJSSpecialChars $ encode $ JSArray $ map (\a -> JSObject $ toJSObject [("value", showJSON a)]) as
   numpostings = 4
diff --git a/Hledger/Web/Main.hs b/Hledger/Web/Main.hs
--- a/Hledger/Web/Main.hs
+++ b/Hledger/Web/Main.hs
@@ -22,7 +22,7 @@
 #if !MIN_VERSION_base(4,8,0)
 import Control.Applicative ((<$>))
 #endif
-import Control.Monad (when)
+import Control.Monad
 import Data.Text (pack)
 import System.Exit (exitSuccess)
 import System.IO (hFlush, stdout)
@@ -59,10 +59,13 @@
   -- Also we may be writing to this file. Just disallow it.
   when (f == "-") $ error' "hledger-web doesn't support -f -, please specify a file path"
 
-  let fn = cmd opts .
-           pivotByOpts cliopts .
-           anonymiseByOpts cliopts .
-           journalApplyAliases (aliasesFromOpts cliopts)
+  let fn = cmd opts
+         . pivotByOpts cliopts
+         . anonymiseByOpts cliopts
+         . journalApplyAliases (aliasesFromOpts cliopts)
+       <=< journalApplyValue (reportopts_ cliopts)
+       <=< journalAddForecast cliopts
+         . generateAutomaticPostings (reportopts_ cliopts)
   readJournalFile Nothing Nothing True f >>= either error' fn
 
 -- | The web command.
diff --git a/doc/hledger-web.1 b/doc/hledger-web.1
deleted file mode 100644
--- a/doc/hledger-web.1
+++ /dev/null
@@ -1,317 +0,0 @@
-
-.TH "hledger\-web" "1" "September 2017" "hledger\-web 1.4" "hledger User Manuals"
-
-
-
-.SH NAME
-.PP
-hledger\-web \- web interface for the hledger accounting tool
-.SH SYNOPSIS
-.PP
-\f[C]hledger\-web\ [OPTIONS]\f[]
-.PD 0
-.P
-.PD
-\f[C]hledger\ web\ \-\-\ [OPTIONS]\f[]
-.SH DESCRIPTION
-.PP
-hledger is a cross\-platform program for tracking money, time, or any
-other commodity, using double\-entry accounting and a simple, editable
-file format.
-hledger is inspired by and largely compatible with ledger(1).
-.PP
-hledger\-web is hledger\[aq]s web interface.
-It starts a simple web application for browsing and adding transactions,
-and optionally opens it in a web browser window if possible.
-It provides a more user\-friendly UI than the hledger CLI or hledger\-ui
-interface, showing more at once (accounts, the current account register,
-balance charts) and allowing history\-aware data entry, interactive
-searching, and bookmarking.
-.PP
-hledger\-web also lets you share a ledger with multiple users, or even
-the public web.
-There is no access control, so if you need that you should put it behind
-a suitable web proxy.
-As a small protection against data loss when running an unprotected
-instance, it writes a numbered backup of the main journal file (only ?)
-on every edit.
-.PP
-Like hledger, it reads data from one or more files in hledger journal,
-timeclock, timedot, or CSV format specified with \f[C]\-f\f[], or
-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,
-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).
-For more about this see hledger(1), hledger_journal(5) etc.
-.PP
-By default, hledger\-web starts the web app in "transient mode" and also
-opens it in your default web browser if possible.
-In this mode the web app will keep running for as long as you have it
-open in a browser window, and will exit after two minutes of inactivity
-(no requests and no browser windows viewing it).
-With \f[C]\-\-serve\f[], it just runs the web app without exiting, and
-logs requests to the console.
-.PP
-By default the server listens on IP address 127.0.0.1, accessible only
-to local requests.
-You can use \f[C]\-\-host\f[] to change this, eg
-\f[C]\-\-host\ 0.0.0.0\f[] to listen on all configured addresses.
-.PP
-Similarly, use \f[C]\-\-port\f[] to set a TCP port other than 5000, eg
-if you are running multiple hledger\-web instances.
-.PP
-You can use \f[C]\-\-base\-url\f[] to change the protocol, hostname,
-port and path that appear in hyperlinks, useful eg for integrating
-hledger\-web within a larger website.
-The default is \f[C]http://HOST:PORT/\f[] using the server\[aq]s
-configured host address and TCP port (or \f[C]http://HOST\f[] if PORT is
-80).
-.PP
-With \f[C]\-\-file\-url\f[] you can set a different base url for static
-files, eg for better caching or cookie\-less serving on high performance
-websites.
-.PP
-Note there is no built\-in access control (aside from listening on
-127.0.0.1 by default).
-So you will need to hide hledger\-web behind an authenticating proxy
-(such as apache or nginx) if you want to restrict who can see and add
-entries to your journal.
-.PP
-Command\-line options and arguments may be used to set an initial filter
-on the data.
-This is not shown in the web UI, but it will be applied in addition to
-any search query entered there.
-.PP
-With journal and timeclock files (but not CSV files, currently) the web
-app detects changes made by other means and will show the new data on
-the next request.
-If a change makes the file unparseable, hledger\-web will show an error
-until the file has been fixed.
-.SH OPTIONS
-.PP
-Note: if invoking hledger\-web as a hledger subcommand, write
-\f[C]\-\-\f[] before options as shown above.
-.TP
-.B \f[C]\-\-serve\f[]
-serve and log requests, don\[aq]t browse or auto\-exit
-.RS
-.RE
-.TP
-.B \f[C]\-\-host=IPADDR\f[]
-listen on this IP address (default: 127.0.0.1)
-.RS
-.RE
-.TP
-.B \f[C]\-\-port=PORT\f[]
-listen on this TCP port (default: 5000)
-.RS
-.RE
-.TP
-.B \f[C]\-\-base\-url=URL\f[]
-set the base url (default: http://IPADDR:PORT).
-You would change this when sharing over the network, or integrating
-within a larger website.
-.RS
-.RE
-.TP
-.B \f[C]\-\-file\-url=URL\f[]
-set the static files url (default: BASEURL/static).
-hledger\-web normally serves static files itself, but if you wanted to
-serve them from another server for efficiency, you would set the url
-with this.
-.RS
-.RE
-.PP
-hledger input options:
-.TP
-.B \f[C]\-f\ FILE\ \-\-file=FILE\f[]
-use a different input file.
-For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or
-\f[C]$HOME/.hledger.journal\f[])
-.RS
-.RE
-.TP
-.B \f[C]\-\-rules\-file=RULESFILE\f[]
-Conversion rules file to use when reading CSV (default: FILE.rules)
-.RS
-.RE
-.TP
-.B \f[C]\-\-alias=OLD=NEW\f[]
-rename accounts named OLD to NEW
-.RS
-.RE
-.TP
-.B \f[C]\-\-anon\f[]
-anonymize accounts and payees
-.RS
-.RE
-.TP
-.B \f[C]\-\-pivot\ FIELDNAME\f[]
-use some other field or tag for the account name
-.RS
-.RE
-.TP
-.B \f[C]\-I\ \-\-ignore\-assertions\f[]
-ignore any failing balance assertions
-.RS
-.RE
-.PP
-hledger reporting options:
-.TP
-.B \f[C]\-b\ \-\-begin=DATE\f[]
-include postings/txns on or after this date
-.RS
-.RE
-.TP
-.B \f[C]\-e\ \-\-end=DATE\f[]
-include postings/txns before this date
-.RS
-.RE
-.TP
-.B \f[C]\-D\ \-\-daily\f[]
-multiperiod/multicolumn report by day
-.RS
-.RE
-.TP
-.B \f[C]\-W\ \-\-weekly\f[]
-multiperiod/multicolumn report by week
-.RS
-.RE
-.TP
-.B \f[C]\-M\ \-\-monthly\f[]
-multiperiod/multicolumn report by month
-.RS
-.RE
-.TP
-.B \f[C]\-Q\ \-\-quarterly\f[]
-multiperiod/multicolumn report by quarter
-.RS
-.RE
-.TP
-.B \f[C]\-Y\ \-\-yearly\f[]
-multiperiod/multicolumn report by year
-.RS
-.RE
-.TP
-.B \f[C]\-p\ \-\-period=PERIODEXP\f[]
-set start date, end date, and/or reporting interval all at once
-(overrides the flags above)
-.RS
-.RE
-.TP
-.B \f[C]\-\-date2\f[]
-match the secondary date instead (see command help for other effects)
-.RS
-.RE
-.TP
-.B \f[C]\-U\ \-\-unmarked\f[]
-include only unmarked postings/txns (can combine with \-P or \-C)
-.RS
-.RE
-.TP
-.B \f[C]\-P\ \-\-pending\f[]
-include only pending postings/txns
-.RS
-.RE
-.TP
-.B \f[C]\-C\ \-\-cleared\f[]
-include only cleared postings/txns
-.RS
-.RE
-.TP
-.B \f[C]\-R\ \-\-real\f[]
-include only non\-virtual postings
-.RS
-.RE
-.TP
-.B \f[C]\-NUM\ \-\-depth=NUM\f[]
-hide/aggregate accounts or postings more than NUM levels deep
-.RS
-.RE
-.TP
-.B \f[C]\-E\ \-\-empty\f[]
-show items with zero amount, normally hidden
-.RS
-.RE
-.TP
-.B \f[C]\-B\ \-\-cost\f[]
-convert amounts to their cost at transaction time (using the transaction
-price, if any)
-.RS
-.RE
-.TP
-.B \f[C]\-V\ \-\-value\f[]
-convert amounts to their market value on the report end date (using the
-most recent applicable market price, if any)
-.RS
-.RE
-.PP
-When a reporting option appears more than once in the command line, the
-last one takes precedence.
-.PP
-Some reporting options can also be written as query arguments.
-.PP
-hledger help options:
-.TP
-.B \f[C]\-h\ \-\-help\f[]
-show general usage (or after COMMAND, command usage)
-.RS
-.RE
-.TP
-.B \f[C]\-\-version\f[]
-show version
-.RS
-.RE
-.TP
-.B \f[C]\-\-debug[=N]\f[]
-show debug output (levels 1\-9, default: 1)
-.RS
-.RE
-.PP
-A \@FILE argument will be expanded to the contents of FILE, which should
-contain one command line option/argument per line.
-(To prevent this, insert a \f[C]\-\-\f[] argument before.)
-.SH ENVIRONMENT
-.PP
-\f[B]LEDGER_FILE\f[] The journal file path when not specified with
-\f[C]\-f\f[].
-Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps
-\f[C]C:/Users/USER/.hledger.journal\f[]).
-.SH FILES
-.PP
-Reads data from one or more files in hledger journal, timeclock,
-timedot, or CSV format specified with \f[C]\-f\f[], or
-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,
-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).
-.SH BUGS
-.PP
-The need to precede options with \f[C]\-\-\f[] when invoked from hledger
-is awkward.
-.PP
-\f[C]\-f\-\f[] doesn\[aq]t work (hledger\-web can\[aq]t read from
-stdin).
-.PP
-Query arguments and some hledger options are ignored.
-.PP
-Does not work in text\-mode browsers.
-.PP
-Does not work well on small screens.
-
-
-.SH "REPORTING BUGS"
-Report bugs at http://bugs.hledger.org
-(or on the #hledger IRC channel or hledger mail list)
-
-.SH AUTHORS
-Simon Michael <simon@joyful.com> and contributors
-
-.SH COPYRIGHT
-
-Copyright (C) 2007-2016 Simon Michael.
-.br
-Released under GNU GPL v3 or later.
-
-.SH SEE ALSO
-hledger(1), hledger\-ui(1), hledger\-web(1), hledger\-api(1),
-hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_timedot(5),
-ledger(1)
-
-http://hledger.org
diff --git a/doc/hledger-web.1.info b/doc/hledger-web.1.info
deleted file mode 100644
--- a/doc/hledger-web.1.info
+++ /dev/null
@@ -1,207 +0,0 @@
-This is hledger-web.1.info, produced by makeinfo version 6.0 from stdin.
-
-
-File: hledger-web.1.info,  Node: Top,  Next: OPTIONS,  Up: (dir)
-
-hledger-web(1) hledger-web 1.4
-******************************
-
-hledger-web is hledger's web interface.  It starts a simple web
-application for browsing and adding transactions, and optionally opens
-it in a web browser window if possible.  It provides a more
-user-friendly UI than the hledger CLI or hledger-ui interface, showing
-more at once (accounts, the current account register, balance charts)
-and allowing history-aware data entry, interactive searching, and
-bookmarking.
-
-   hledger-web also lets you share a ledger with multiple users, or even
-the public web.  There is no access control, so if you need that you
-should put it behind a suitable web proxy.  As a small protection
-against data loss when running an unprotected instance, it writes a
-numbered backup of the main journal file (only ?)  on every edit.
-
-   Like hledger, it reads data from one or more files in hledger
-journal, timeclock, timedot, or CSV format specified with '-f', or
-'$LEDGER_FILE', or '$HOME/.hledger.journal' (on windows, perhaps
-'C:/Users/USER/.hledger.journal').  For more about this see hledger(1),
-hledger_journal(5) etc.
-
-   By default, hledger-web starts the web app in "transient mode" and
-also opens it in your default web browser if possible.  In this mode the
-web app will keep running for as long as you have it open in a browser
-window, and will exit after two minutes of inactivity (no requests and
-no browser windows viewing it).  With '--serve', it just runs the web
-app without exiting, and logs requests to the console.
-
-   By default the server listens on IP address 127.0.0.1, accessible
-only to local requests.  You can use '--host' to change this, eg '--host
-0.0.0.0' to listen on all configured addresses.
-
-   Similarly, use '--port' to set a TCP port other than 5000, eg if you
-are running multiple hledger-web instances.
-
-   You can use '--base-url' to change the protocol, hostname, port and
-path that appear in hyperlinks, useful eg for integrating hledger-web
-within a larger website.  The default is 'http://HOST:PORT/' using the
-server's configured host address and TCP port (or 'http://HOST' if PORT
-is 80).
-
-   With '--file-url' you can set a different base url for static files,
-eg for better caching or cookie-less serving on high performance
-websites.
-
-   Note there is no built-in access control (aside from listening on
-127.0.0.1 by default).  So you will need to hide hledger-web behind an
-authenticating proxy (such as apache or nginx) if you want to restrict
-who can see and add entries to your journal.
-
-   Command-line options and arguments may be used to set an initial
-filter on the data.  This is not shown in the web UI, but it will be
-applied in addition to any search query entered there.
-
-   With journal and timeclock files (but not CSV files, currently) the
-web app detects changes made by other means and will show the new data
-on the next request.  If a change makes the file unparseable,
-hledger-web will show an error until the file has been fixed.
-* Menu:
-
-* OPTIONS::
-
-
-File: hledger-web.1.info,  Node: OPTIONS,  Prev: Top,  Up: Top
-
-1 OPTIONS
-*********
-
-Note: if invoking hledger-web as a hledger subcommand, write '--' before
-options as shown above.
-
-'--serve'
-
-     serve and log requests, don't browse or auto-exit
-'--host=IPADDR'
-
-     listen on this IP address (default: 127.0.0.1)
-'--port=PORT'
-
-     listen on this TCP port (default: 5000)
-'--base-url=URL'
-
-     set the base url (default: http://IPADDR:PORT). You would change
-     this when sharing over the network, or integrating within a larger
-     website.
-'--file-url=URL'
-
-     set the static files url (default: BASEURL/static).  hledger-web
-     normally serves static files itself, but if you wanted to serve
-     them from another server for efficiency, you would set the url with
-     this.
-
-   hledger input options:
-
-'-f FILE --file=FILE'
-
-     use a different input file.  For stdin, use - (default:
-     '$LEDGER_FILE' or '$HOME/.hledger.journal')
-'--rules-file=RULESFILE'
-
-     Conversion rules file to use when reading CSV (default: FILE.rules)
-'--alias=OLD=NEW'
-
-     rename accounts named OLD to NEW
-'--anon'
-
-     anonymize accounts and payees
-'--pivot FIELDNAME'
-
-     use some other field or tag for the account name
-'-I --ignore-assertions'
-
-     ignore any failing balance assertions
-
-   hledger reporting options:
-
-'-b --begin=DATE'
-
-     include postings/txns on or after this date
-'-e --end=DATE'
-
-     include postings/txns before this date
-'-D --daily'
-
-     multiperiod/multicolumn report by day
-'-W --weekly'
-
-     multiperiod/multicolumn report by week
-'-M --monthly'
-
-     multiperiod/multicolumn report by month
-'-Q --quarterly'
-
-     multiperiod/multicolumn report by quarter
-'-Y --yearly'
-
-     multiperiod/multicolumn report by year
-'-p --period=PERIODEXP'
-
-     set start date, end date, and/or reporting interval all at once
-     (overrides the flags above)
-'--date2'
-
-     match the secondary date instead (see command help for other
-     effects)
-'-U --unmarked'
-
-     include only unmarked postings/txns (can combine with -P or -C)
-'-P --pending'
-
-     include only pending postings/txns
-'-C --cleared'
-
-     include only cleared postings/txns
-'-R --real'
-
-     include only non-virtual postings
-'-NUM --depth=NUM'
-
-     hide/aggregate accounts or postings more than NUM levels deep
-'-E --empty'
-
-     show items with zero amount, normally hidden
-'-B --cost'
-
-     convert amounts to their cost at transaction time (using the
-     transaction price, if any)
-'-V --value'
-
-     convert amounts to their market value on the report end date (using
-     the most recent applicable market price, if any)
-
-   When a reporting option appears more than once in the command line,
-the last one takes precedence.
-
-   Some reporting options can also be written as query arguments.
-
-   hledger help options:
-
-'-h --help'
-
-     show general usage (or after COMMAND, command usage)
-'--version'
-
-     show version
-'--debug[=N]'
-
-     show debug output (levels 1-9, default: 1)
-
-   A @FILE argument will be expanded to the contents of FILE, which
-should contain one command line option/argument per line.  (To prevent
-this, insert a '--' argument before.)
-
-
-Tag Table:
-Node: Top74
-Node: OPTIONS3156
-Ref: #options3243
-
-End Tag Table
diff --git a/doc/hledger-web.1.txt b/doc/hledger-web.1.txt
deleted file mode 100644
--- a/doc/hledger-web.1.txt
+++ /dev/null
@@ -1,244 +0,0 @@
-
-hledger-web(1)               hledger User Manuals               hledger-web(1)
-
-
-
-NAME
-       hledger-web - web interface for the hledger accounting tool
-
-SYNOPSIS
-       hledger-web [OPTIONS]
-       hledger web -- [OPTIONS]
-
-DESCRIPTION
-       hledger  is  a  cross-platform program for tracking money, time, or any
-       other commodity, using double-entry accounting and a  simple,  editable
-       file  format.   hledger  is  inspired  by  and  largely compatible with
-       ledger(1).
-
-       hledger-web is hledger's web interface.  It starts a simple web  appli-
-       cation for browsing and adding transactions, and optionally opens it in
-       a web browser window if possible.  It provides a more user-friendly  UI
-       than  the  hledger  CLI  or  hledger-ui interface, showing more at once
-       (accounts, the current account register, balance charts)  and  allowing
-       history-aware data entry, interactive searching, and bookmarking.
-
-       hledger-web  also  lets you share a ledger with multiple users, or even
-       the public web.  There is no access control, so if you  need  that  you
-       should  put  it  behind  a  suitable  web proxy.  As a small protection
-       against data loss when running an unprotected  instance,  it  writes  a
-       numbered backup of the main journal file (only ?)  on every edit.
-
-       Like  hledger, it reads data from one or more files in hledger journal,
-       timeclock, timedot, or CSV format specified with -f,  or  $LEDGER_FILE,
-       or        $HOME/.hledger.journal       (on       windows,       perhaps
-       C:/Users/USER/.hledger.journal).  For more about this  see  hledger(1),
-       hledger_journal(5) etc.
-
-       By default, hledger-web starts the web app in "transient mode" and also
-       opens it in your default web browser if possible.  In this mode the web
-       app will keep running for as long as you have it open in a browser win-
-       dow, and will exit after two minutes of inactivity (no requests and  no
-       browser  windows  viewing  it).  With --serve, it just runs the web app
-       without exiting, and logs requests to the console.
-
-       By default the server listens on IP address 127.0.0.1, accessible  only
-       to   local   requests.    You   can  use  --host  to  change  this,  eg
-       --host 0.0.0.0 to listen on all configured addresses.
-
-       Similarly, use --port to set a TCP port other than 5000, eg if you  are
-       running multiple hledger-web instances.
-
-       You  can use --base-url to change the protocol, hostname, port and path
-       that appear in hyperlinks, useful eg for integrating hledger-web within
-       a  larger website.  The default is http://HOST:PORT/ using the server's
-       configured host address and TCP port (or http://HOST if PORT is 80).
-
-       With --file-url you can set a different base url for static  files,  eg
-       for better caching or cookie-less serving on high performance websites.
-
-       Note there is no built-in  access  control  (aside  from  listening  on
-       127.0.0.1  by default).  So you will need to hide hledger-web behind an
-       authenticating proxy (such as apache or nginx) if you want to  restrict
-       who can see and add entries to your journal.
-
-       Command-line options and arguments may be used to set an initial filter
-       on the data.  This is not shown in the web UI, but it will  be  applied
-       in addition to any search query entered there.
-
-       With journal and timeclock files (but not CSV files, currently) the web
-       app detects changes made by other means and will show the new  data  on
-       the  next request.  If a change makes the file unparseable, hledger-web
-       will show an error until the file has been fixed.
-
-OPTIONS
-       Note: if invoking hledger-web as a hledger subcommand, write --  before
-       options as shown above.
-
-       --serve
-              serve and log requests, don't browse or auto-exit
-
-       --host=IPADDR
-              listen on this IP address (default: 127.0.0.1)
-
-       --port=PORT
-              listen on this TCP port (default: 5000)
-
-       --base-url=URL
-              set  the  base  url  (default:  http://IPADDR:PORT).   You would
-              change this when sharing over the network, or integrating within
-              a larger website.
-
-       --file-url=URL
-              set the static files url (default: BASEURL/static).  hledger-web
-              normally serves static files itself, but if you wanted to  serve
-              them  from  another server for efficiency, you would set the url
-              with this.
-
-       hledger input options:
-
-       -f FILE --file=FILE
-              use  a  different  input  file.   For  stdin,  use  -  (default:
-              $LEDGER_FILE or $HOME/.hledger.journal)
-
-       --rules-file=RULESFILE
-              Conversion   rules  file  to  use  when  reading  CSV  (default:
-              FILE.rules)
-
-       --alias=OLD=NEW
-              rename accounts named OLD to NEW
-
-       --anon anonymize accounts and payees
-
-       --pivot FIELDNAME
-              use some other field or tag for the account name
-
-       -I --ignore-assertions
-              ignore any failing balance assertions
-
-       hledger reporting options:
-
-       -b --begin=DATE
-              include postings/txns on or after this date
-
-       -e --end=DATE
-              include postings/txns before this date
-
-       -D --daily
-              multiperiod/multicolumn report by day
-
-       -W --weekly
-              multiperiod/multicolumn report by week
-
-       -M --monthly
-              multiperiod/multicolumn report by month
-
-       -Q --quarterly
-              multiperiod/multicolumn report by quarter
-
-       -Y --yearly
-              multiperiod/multicolumn report by year
-
-       -p --period=PERIODEXP
-              set start date, end date, and/or reporting interval all at  once
-              (overrides the flags above)
-
-       --date2
-              match  the  secondary  date  instead (see command help for other
-              effects)
-
-       -U --unmarked
-              include only unmarked postings/txns (can combine with -P or -C)
-
-       -P --pending
-              include only pending postings/txns
-
-       -C --cleared
-              include only cleared postings/txns
-
-       -R --real
-              include only non-virtual postings
-
-       -NUM --depth=NUM
-              hide/aggregate accounts or postings more than NUM levels deep
-
-       -E --empty
-              show items with zero amount, normally hidden
-
-       -B --cost
-              convert amounts to their cost at  transaction  time  (using  the
-              transaction price, if any)
-
-       -V --value
-              convert  amounts  to  their  market value on the report end date
-              (using the most recent applicable market price, if any)
-
-       When a reporting option appears more than once in the command line, the
-       last one takes precedence.
-
-       Some reporting options can also be written as query arguments.
-
-       hledger help options:
-
-       -h --help
-              show general usage (or after COMMAND, command usage)
-
-       --version
-              show version
-
-       --debug[=N]
-              show debug output (levels 1-9, default: 1)
-
-       A @FILE argument will be expanded to the contents of FILE, which should
-       contain one command line option/argument per line.  (To  prevent  this,
-       insert a -- argument before.)
-
-ENVIRONMENT
-       LEDGER_FILE The journal file path when not specified with -f.  Default:
-       ~/.hledger.journal (on  windows,  perhaps  C:/Users/USER/.hledger.jour-
-       nal).
-
-FILES
-       Reads  data from one or more files in hledger journal, timeclock, time-
-       dot,  or  CSV  format  specified   with   -f,   or   $LEDGER_FILE,   or
-       $HOME/.hledger.journal           (on          windows,          perhaps
-       C:/Users/USER/.hledger.journal).
-
-BUGS
-       The need to precede options with -- when invoked from hledger  is  awk-
-       ward.
-
-       -f- doesn't work (hledger-web can't read from stdin).
-
-       Query arguments and some hledger options are ignored.
-
-       Does not work in text-mode browsers.
-
-       Does not work well on small screens.
-
-
-
-REPORTING BUGS
-       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel
-       or hledger mail list)
-
-
-AUTHORS
-       Simon Michael <simon@joyful.com> and contributors
-
-
-COPYRIGHT
-       Copyright (C) 2007-2016 Simon Michael.
-       Released under GNU GPL v3 or later.
-
-
-SEE ALSO
-       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),
-       hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
-       dot(5), ledger(1)
-
-       http://hledger.org
-
-
-
-hledger-web 1.4                 September 2017                  hledger-web(1)
diff --git a/hledger-web.1 b/hledger-web.1
new file mode 100644
--- /dev/null
+++ b/hledger-web.1
@@ -0,0 +1,326 @@
+
+.TH "hledger\-web" "1" "December 2017" "hledger\-web 1.5" "hledger User Manuals"
+
+
+
+.SH NAME
+.PP
+hledger\-web \- web interface for the hledger accounting tool
+.SH SYNOPSIS
+.PP
+\f[C]hledger\-web\ [OPTIONS]\f[]
+.PD 0
+.P
+.PD
+\f[C]hledger\ web\ \-\-\ [OPTIONS]\f[]
+.SH DESCRIPTION
+.PP
+hledger is a cross\-platform program for tracking money, time, or any
+other commodity, using double\-entry accounting and a simple, editable
+file format.
+hledger is inspired by and largely compatible with ledger(1).
+.PP
+hledger\-web is hledger's web interface.
+It starts a simple web application for browsing and adding transactions,
+and optionally opens it in a web browser window if possible.
+It provides a more user\-friendly UI than the hledger CLI or hledger\-ui
+interface, showing more at once (accounts, the current account register,
+balance charts) and allowing history\-aware data entry, interactive
+searching, and bookmarking.
+.PP
+hledger\-web also lets you share a ledger with multiple users, or even
+the public web.
+There is no access control, so if you need that you should put it behind
+a suitable web proxy.
+As a small protection against data loss when running an unprotected
+instance, it writes a numbered backup of the main journal file (only ?)
+on every edit.
+.PP
+Like hledger, it reads data from one or more files in hledger journal,
+timeclock, timedot, or CSV format specified with \f[C]\-f\f[], or
+\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,
+perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).
+For more about this see hledger(1), hledger_journal(5) etc.
+.PP
+By default, hledger\-web starts the web app in \[lq]transient mode\[rq]
+and also opens it in your default web browser if possible.
+In this mode the web app will keep running for as long as you have it
+open in a browser window, and will exit after two minutes of inactivity
+(no requests and no browser windows viewing it).
+With \f[C]\-\-serve\f[], it just runs the web app without exiting, and
+logs requests to the console.
+.PP
+By default the server listens on IP address 127.0.0.1, accessible only
+to local requests.
+You can use \f[C]\-\-host\f[] to change this, eg
+\f[C]\-\-host\ 0.0.0.0\f[] to listen on all configured addresses.
+.PP
+Similarly, use \f[C]\-\-port\f[] to set a TCP port other than 5000, eg
+if you are running multiple hledger\-web instances.
+.PP
+You can use \f[C]\-\-base\-url\f[] to change the protocol, hostname,
+port and path that appear in hyperlinks, useful eg for integrating
+hledger\-web within a larger website.
+The default is \f[C]http://HOST:PORT/\f[] using the server's configured
+host address and TCP port (or \f[C]http://HOST\f[] if PORT is 80).
+.PP
+With \f[C]\-\-file\-url\f[] you can set a different base url for static
+files, eg for better caching or cookie\-less serving on high performance
+websites.
+.PP
+Note there is no built\-in access control (aside from listening on
+127.0.0.1 by default).
+So you will need to hide hledger\-web behind an authenticating proxy
+(such as apache or nginx) if you want to restrict who can see and add
+entries to your journal.
+.PP
+Command\-line options and arguments may be used to set an initial filter
+on the data.
+This is not shown in the web UI, but it will be applied in addition to
+any search query entered there.
+.PP
+With journal and timeclock files (but not CSV files, currently) the web
+app detects changes made by other means and will show the new data on
+the next request.
+If a change makes the file unparseable, hledger\-web will show an error
+until the file has been fixed.
+.SH OPTIONS
+.PP
+Note: if invoking hledger\-web as a hledger subcommand, write
+\f[C]\-\-\f[] before options as shown above.
+.TP
+.B \f[C]\-\-serve\f[]
+serve and log requests, don't browse or auto\-exit
+.RS
+.RE
+.TP
+.B \f[C]\-\-host=IPADDR\f[]
+listen on this IP address (default: 127.0.0.1)
+.RS
+.RE
+.TP
+.B \f[C]\-\-port=PORT\f[]
+listen on this TCP port (default: 5000)
+.RS
+.RE
+.TP
+.B \f[C]\-\-base\-url=URL\f[]
+set the base url (default: http://IPADDR:PORT).
+You would change this when sharing over the network, or integrating
+within a larger website.
+.RS
+.RE
+.TP
+.B \f[C]\-\-file\-url=URL\f[]
+set the static files url (default: BASEURL/static).
+hledger\-web normally serves static files itself, but if you wanted to
+serve them from another server for efficiency, you would set the url
+with this.
+.RS
+.RE
+.PP
+hledger input options:
+.TP
+.B \f[C]\-f\ FILE\ \-\-file=FILE\f[]
+use a different input file.
+For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or
+\f[C]$HOME/.hledger.journal\f[])
+.RS
+.RE
+.TP
+.B \f[C]\-\-rules\-file=RULESFILE\f[]
+Conversion rules file to use when reading CSV (default: FILE.rules)
+.RS
+.RE
+.TP
+.B \f[C]\-\-alias=OLD=NEW\f[]
+rename accounts named OLD to NEW
+.RS
+.RE
+.TP
+.B \f[C]\-\-anon\f[]
+anonymize accounts and payees
+.RS
+.RE
+.TP
+.B \f[C]\-\-pivot\ FIELDNAME\f[]
+use some other field or tag for the account name
+.RS
+.RE
+.TP
+.B \f[C]\-I\ \-\-ignore\-assertions\f[]
+ignore any failing balance assertions
+.RS
+.RE
+.PP
+hledger reporting options:
+.TP
+.B \f[C]\-b\ \-\-begin=DATE\f[]
+include postings/txns on or after this date
+.RS
+.RE
+.TP
+.B \f[C]\-e\ \-\-end=DATE\f[]
+include postings/txns before this date
+.RS
+.RE
+.TP
+.B \f[C]\-D\ \-\-daily\f[]
+multiperiod/multicolumn report by day
+.RS
+.RE
+.TP
+.B \f[C]\-W\ \-\-weekly\f[]
+multiperiod/multicolumn report by week
+.RS
+.RE
+.TP
+.B \f[C]\-M\ \-\-monthly\f[]
+multiperiod/multicolumn report by month
+.RS
+.RE
+.TP
+.B \f[C]\-Q\ \-\-quarterly\f[]
+multiperiod/multicolumn report by quarter
+.RS
+.RE
+.TP
+.B \f[C]\-Y\ \-\-yearly\f[]
+multiperiod/multicolumn report by year
+.RS
+.RE
+.TP
+.B \f[C]\-p\ \-\-period=PERIODEXP\f[]
+set start date, end date, and/or reporting interval all at once using
+period expressions syntax (overrides the flags above)
+.RS
+.RE
+.TP
+.B \f[C]\-\-date2\f[]
+match the secondary date instead (see command help for other effects)
+.RS
+.RE
+.TP
+.B \f[C]\-U\ \-\-unmarked\f[]
+include only unmarked postings/txns (can combine with \-P or \-C)
+.RS
+.RE
+.TP
+.B \f[C]\-P\ \-\-pending\f[]
+include only pending postings/txns
+.RS
+.RE
+.TP
+.B \f[C]\-C\ \-\-cleared\f[]
+include only cleared postings/txns
+.RS
+.RE
+.TP
+.B \f[C]\-R\ \-\-real\f[]
+include only non\-virtual postings
+.RS
+.RE
+.TP
+.B \f[C]\-NUM\ \-\-depth=NUM\f[]
+hide/aggregate accounts or postings more than NUM levels deep
+.RS
+.RE
+.TP
+.B \f[C]\-E\ \-\-empty\f[]
+show items with zero amount, normally hidden
+.RS
+.RE
+.TP
+.B \f[C]\-B\ \-\-cost\f[]
+convert amounts to their cost at transaction time (using the transaction
+price, if any)
+.RS
+.RE
+.TP
+.B \f[C]\-V\ \-\-value\f[]
+convert amounts to their market value on the report end date (using the
+most recent applicable market price, if any)
+.RS
+.RE
+.TP
+.B \f[C]\-\-auto\f[]
+apply automated posting rules to modify transactions.
+.RS
+.RE
+.TP
+.B \f[C]\-\-forecast\f[]
+apply periodic transaction rules to generate future transactions, to 6
+months from now or report end date.
+.RS
+.RE
+.PP
+When a reporting option appears more than once in the command line, the
+last one takes precedence.
+.PP
+Some reporting options can also be written as query arguments.
+.PP
+hledger help options:
+.TP
+.B \f[C]\-h\ \-\-help\f[]
+show general usage (or after COMMAND, command usage)
+.RS
+.RE
+.TP
+.B \f[C]\-\-version\f[]
+show version
+.RS
+.RE
+.TP
+.B \f[C]\-\-debug[=N]\f[]
+show debug output (levels 1\-9, default: 1)
+.RS
+.RE
+.PP
+A \@FILE argument will be expanded to the contents of FILE, which should
+contain one command line option/argument per line.
+(To prevent this, insert a \f[C]\-\-\f[] argument before.)
+.SH ENVIRONMENT
+.PP
+\f[B]LEDGER_FILE\f[] The journal file path when not specified with
+\f[C]\-f\f[].
+Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps
+\f[C]C:/Users/USER/.hledger.journal\f[]).
+.SH FILES
+.PP
+Reads data from one or more files in hledger journal, timeclock,
+timedot, or CSV format specified with \f[C]\-f\f[], or
+\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,
+perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).
+.SH BUGS
+.PP
+The need to precede options with \f[C]\-\-\f[] when invoked from hledger
+is awkward.
+.PP
+\f[C]\-f\-\f[] doesn't work (hledger\-web can't read from stdin).
+.PP
+Query arguments and some hledger options are ignored.
+.PP
+Does not work in text\-mode browsers.
+.PP
+Does not work well on small screens.
+
+
+.SH "REPORTING BUGS"
+Report bugs at http://bugs.hledger.org
+(or on the #hledger IRC channel or hledger mail list)
+
+.SH AUTHORS
+Simon Michael <simon@joyful.com> and contributors
+
+.SH COPYRIGHT
+
+Copyright (C) 2007-2016 Simon Michael.
+.br
+Released under GNU GPL v3 or later.
+
+.SH SEE ALSO
+hledger(1), hledger\-ui(1), hledger\-web(1), hledger\-api(1),
+hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_timedot(5),
+ledger(1)
+
+http://hledger.org
diff --git a/hledger-web.cabal b/hledger-web.cabal
--- a/hledger-web.cabal
+++ b/hledger-web.cabal
@@ -1,9 +1,11 @@
--- This file has been generated from package.yaml by hpack version 0.17.1.
+-- This file has been generated from package.yaml by hpack version 0.20.0.
 --
 -- see: https://github.com/sol/hpack
+--
+-- hash: 4b29b9e5703c56c1f7beabdcec14cf3007d6f6c6855088b8bf06da8f092b4b3d
 
 name:           hledger-web
-version:        1.4
+version:        1.5
 synopsis:       Web interface for the hledger accounting tool
 description:    This is hledger's web interface.
                 It provides a more user-friendly and collaborative UI than the
@@ -36,6 +38,7 @@
     config/settings.yml
     messages/en.msg
     README
+    static/css/bootstrap-datepicker.standalone.min.css
     static/css/bootstrap-theme.css
     static/css/bootstrap-theme.css.map
     static/css/bootstrap-theme.min.css
@@ -48,6 +51,7 @@
     static/fonts/glyphicons-halflings-regular.woff
     static/hledger.css
     static/hledger.js
+    static/js/bootstrap-datepicker.min.js
     static/js/bootstrap.js
     static/js/bootstrap.min.js
     static/js/excanvas.js
@@ -95,9 +99,9 @@
     templates/default-layout.hamlet
 
 data-files:
-    doc/hledger-web.1
-    doc/hledger-web.1.info
-    doc/hledger-web.1.txt
+    hledger-web.1
+    hledger-web.info
+    hledger-web.txt
 
 source-repository head
   type: git
@@ -120,29 +124,33 @@
 
 library
   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
-  cpp-options: -DVERSION="1.4"
+  cpp-options: -DVERSION="1.5"
   build-depends:
-      hledger-lib >= 1.4 && < 1.5
-    , hledger >= 1.4 && < 1.5
+      HUnit
     , base >=4.8 && <5
     , base-compat >=0.8.1
     , blaze-html
     , blaze-markup
     , bytestring
     , clientsession
-    , cmdargs >=0.10 && <0.11
+    , cmdargs >=0.10
+    , conduit-extra >=1.1
     , data-default
     , directory
     , filepath
     , hjsmin
-    , http-conduit
+    , hledger >=1.5 && <1.6
+    , hledger-lib >=1.5 && <1.6
     , http-client
-    , HUnit
-    , conduit-extra >=1.1
+    , http-conduit
+    , json
+    , megaparsec >=5.0
+    , mtl
+    , parsec >=3
     , safe >=0.2
-    , shakespeare >=2.0.2.2 && < 2.1
+    , shakespeare >=2.0.2.2
     , template-haskell
-    , text >=1.2 && <1.3
+    , text >=1.2
     , time >=1.5
     , transformers
     , wai
@@ -150,14 +158,10 @@
     , wai-handler-launch >=1.3
     , warp
     , yaml
-    , yesod >=1.4 && <1.5
+    , yesod >=1.4
     , yesod-core
     , yesod-form
     , yesod-static
-    , json
-    , megaparsec >=5.0 && < 6.2
-    , mtl
-    , parsec >=3
   if (flag(dev)) || (flag(library-only))
     cpp-options: -DDEVELOPMENT
   if flag(dev)
@@ -188,29 +192,34 @@
   hs-source-dirs:
       app
   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
-  cpp-options: -DVERSION="1.4"
+  cpp-options: -DVERSION="1.5"
   build-depends:
-      hledger-lib >= 1.4 && < 1.5
-    , hledger >= 1.4 && < 1.5
+      HUnit
     , base >=4.8 && <5
     , base-compat >=0.8.1
     , blaze-html
     , blaze-markup
     , bytestring
     , clientsession
-    , cmdargs >=0.10 && <0.11
+    , cmdargs >=0.10
+    , conduit-extra >=1.1
     , data-default
     , directory
     , filepath
     , hjsmin
-    , http-conduit
+    , hledger >=1.5 && <1.6
+    , hledger-lib >=1.5 && <1.6
+    , hledger-web
     , http-client
-    , HUnit
-    , conduit-extra >=1.1
+    , http-conduit
+    , json
+    , megaparsec >=5.0
+    , mtl
+    , parsec >=3
     , safe >=0.2
-    , shakespeare >=2.0.2.2 && < 2.1
+    , shakespeare >=2.0.2.2
     , template-haskell
-    , text >=1.2 && <1.3
+    , text >=1.2
     , time >=1.5
     , transformers
     , wai
@@ -218,15 +227,10 @@
     , wai-handler-launch >=1.3
     , warp
     , yaml
-    , yesod >=1.4 && <1.5
+    , yesod >=1.4
     , yesod-core
     , yesod-form
     , yesod-static
-    , json
-    , megaparsec >=5.0 && < 6.2
-    , mtl
-    , parsec >=3
-    , hledger-web
   if (flag(dev)) || (flag(library-only))
     cpp-options: -DDEVELOPMENT
   if flag(dev)
@@ -235,6 +239,8 @@
     buildable: False
   if flag(threaded)
     ghc-options: -threaded
+  other-modules:
+      Paths_hledger_web
   default-language: Haskell2010
 
 test-suite test
@@ -243,29 +249,35 @@
   hs-source-dirs:
       tests
   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
-  cpp-options: -DVERSION="1.4"
+  cpp-options: -DVERSION="1.5"
   build-depends:
-      hledger-lib >= 1.4 && < 1.5
-    , hledger >= 1.4 && < 1.5
+      HUnit
     , base >=4.8 && <5
     , base-compat >=0.8.1
     , blaze-html
     , blaze-markup
     , bytestring
     , clientsession
-    , cmdargs >=0.10 && <0.11
+    , cmdargs >=0.10
+    , conduit-extra >=1.1
     , data-default
     , directory
     , filepath
     , hjsmin
-    , http-conduit
+    , hledger >=1.5 && <1.6
+    , hledger-lib >=1.5 && <1.6
+    , hledger-web
+    , hspec
     , http-client
-    , HUnit
-    , conduit-extra >=1.1
+    , http-conduit
+    , json
+    , megaparsec >=5.0
+    , mtl
+    , parsec >=3
     , safe >=0.2
-    , shakespeare >=2.0.2.2 && < 2.1
+    , shakespeare >=2.0.2.2
     , template-haskell
-    , text >=1.2 && <1.3
+    , text >=1.2
     , time >=1.5
     , transformers
     , wai
@@ -273,16 +285,10 @@
     , wai-handler-launch >=1.3
     , warp
     , yaml
-    , yesod >=1.4 && <1.5
+    , yesod >=1.4
     , yesod-core
     , yesod-form
     , yesod-static
-    , json
-    , megaparsec >=5.0 && < 6.2
-    , mtl
-    , parsec >=3
-    , hledger-web
-    , hspec
     , yesod-test
   if (flag(dev)) || (flag(library-only))
     cpp-options: -DDEVELOPMENT
@@ -291,4 +297,5 @@
   other-modules:
       HomeTest
       TestImport
+      Paths_hledger_web
   default-language: Haskell2010
diff --git a/hledger-web.info b/hledger-web.info
new file mode 100644
--- /dev/null
+++ b/hledger-web.info
@@ -0,0 +1,214 @@
+This is hledger-web.info, produced by makeinfo version 6.5 from stdin.
+
+
+File: hledger-web.info,  Node: Top,  Next: OPTIONS,  Up: (dir)
+
+hledger-web(1) hledger-web 1.5
+******************************
+
+hledger-web is hledger's web interface.  It starts a simple web
+application for browsing and adding transactions, and optionally opens
+it in a web browser window if possible.  It provides a more
+user-friendly UI than the hledger CLI or hledger-ui interface, showing
+more at once (accounts, the current account register, balance charts)
+and allowing history-aware data entry, interactive searching, and
+bookmarking.
+
+   hledger-web also lets you share a ledger with multiple users, or even
+the public web.  There is no access control, so if you need that you
+should put it behind a suitable web proxy.  As a small protection
+against data loss when running an unprotected instance, it writes a
+numbered backup of the main journal file (only ?)  on every edit.
+
+   Like hledger, it reads data from one or more files in hledger
+journal, timeclock, timedot, or CSV format specified with '-f', or
+'$LEDGER_FILE', or '$HOME/.hledger.journal' (on windows, perhaps
+'C:/Users/USER/.hledger.journal').  For more about this see hledger(1),
+hledger_journal(5) etc.
+
+   By default, hledger-web starts the web app in "transient mode" and
+also opens it in your default web browser if possible.  In this mode the
+web app will keep running for as long as you have it open in a browser
+window, and will exit after two minutes of inactivity (no requests and
+no browser windows viewing it).  With '--serve', it just runs the web
+app without exiting, and logs requests to the console.
+
+   By default the server listens on IP address 127.0.0.1, accessible
+only to local requests.  You can use '--host' to change this, eg '--host
+0.0.0.0' to listen on all configured addresses.
+
+   Similarly, use '--port' to set a TCP port other than 5000, eg if you
+are running multiple hledger-web instances.
+
+   You can use '--base-url' to change the protocol, hostname, port and
+path that appear in hyperlinks, useful eg for integrating hledger-web
+within a larger website.  The default is 'http://HOST:PORT/' using the
+server's configured host address and TCP port (or 'http://HOST' if PORT
+is 80).
+
+   With '--file-url' you can set a different base url for static files,
+eg for better caching or cookie-less serving on high performance
+websites.
+
+   Note there is no built-in access control (aside from listening on
+127.0.0.1 by default).  So you will need to hide hledger-web behind an
+authenticating proxy (such as apache or nginx) if you want to restrict
+who can see and add entries to your journal.
+
+   Command-line options and arguments may be used to set an initial
+filter on the data.  This is not shown in the web UI, but it will be
+applied in addition to any search query entered there.
+
+   With journal and timeclock files (but not CSV files, currently) the
+web app detects changes made by other means and will show the new data
+on the next request.  If a change makes the file unparseable,
+hledger-web will show an error until the file has been fixed.
+* Menu:
+
+* OPTIONS::
+
+
+File: hledger-web.info,  Node: OPTIONS,  Prev: Top,  Up: Top
+
+1 OPTIONS
+*********
+
+Note: if invoking hledger-web as a hledger subcommand, write '--' before
+options as shown above.
+
+'--serve'
+
+     serve and log requests, don't browse or auto-exit
+'--host=IPADDR'
+
+     listen on this IP address (default: 127.0.0.1)
+'--port=PORT'
+
+     listen on this TCP port (default: 5000)
+'--base-url=URL'
+
+     set the base url (default: http://IPADDR:PORT). You would change
+     this when sharing over the network, or integrating within a larger
+     website.
+'--file-url=URL'
+
+     set the static files url (default: BASEURL/static).  hledger-web
+     normally serves static files itself, but if you wanted to serve
+     them from another server for efficiency, you would set the url with
+     this.
+
+   hledger input options:
+
+'-f FILE --file=FILE'
+
+     use a different input file.  For stdin, use - (default:
+     '$LEDGER_FILE' or '$HOME/.hledger.journal')
+'--rules-file=RULESFILE'
+
+     Conversion rules file to use when reading CSV (default: FILE.rules)
+'--alias=OLD=NEW'
+
+     rename accounts named OLD to NEW
+'--anon'
+
+     anonymize accounts and payees
+'--pivot FIELDNAME'
+
+     use some other field or tag for the account name
+'-I --ignore-assertions'
+
+     ignore any failing balance assertions
+
+   hledger reporting options:
+
+'-b --begin=DATE'
+
+     include postings/txns on or after this date
+'-e --end=DATE'
+
+     include postings/txns before this date
+'-D --daily'
+
+     multiperiod/multicolumn report by day
+'-W --weekly'
+
+     multiperiod/multicolumn report by week
+'-M --monthly'
+
+     multiperiod/multicolumn report by month
+'-Q --quarterly'
+
+     multiperiod/multicolumn report by quarter
+'-Y --yearly'
+
+     multiperiod/multicolumn report by year
+'-p --period=PERIODEXP'
+
+     set start date, end date, and/or reporting interval all at once
+     using period expressions syntax (overrides the flags above)
+'--date2'
+
+     match the secondary date instead (see command help for other
+     effects)
+'-U --unmarked'
+
+     include only unmarked postings/txns (can combine with -P or -C)
+'-P --pending'
+
+     include only pending postings/txns
+'-C --cleared'
+
+     include only cleared postings/txns
+'-R --real'
+
+     include only non-virtual postings
+'-NUM --depth=NUM'
+
+     hide/aggregate accounts or postings more than NUM levels deep
+'-E --empty'
+
+     show items with zero amount, normally hidden
+'-B --cost'
+
+     convert amounts to their cost at transaction time (using the
+     transaction price, if any)
+'-V --value'
+
+     convert amounts to their market value on the report end date (using
+     the most recent applicable market price, if any)
+'--auto'
+
+     apply automated posting rules to modify transactions.
+'--forecast'
+
+     apply periodic transaction rules to generate future transactions,
+     to 6 months from now or report end date.
+
+   When a reporting option appears more than once in the command line,
+the last one takes precedence.
+
+   Some reporting options can also be written as query arguments.
+
+   hledger help options:
+
+'-h --help'
+
+     show general usage (or after COMMAND, command usage)
+'--version'
+
+     show version
+'--debug[=N]'
+
+     show debug output (levels 1-9, default: 1)
+
+   A @FILE argument will be expanded to the contents of FILE, which
+should contain one command line option/argument per line.  (To prevent
+this, insert a '--' argument before.)
+
+
+Tag Table:
+Node: Top72
+Node: OPTIONS3152
+Ref: #options3237
+
+End Tag Table
diff --git a/hledger-web.txt b/hledger-web.txt
new file mode 100644
--- /dev/null
+++ b/hledger-web.txt
@@ -0,0 +1,250 @@
+
+hledger-web(1)               hledger User Manuals               hledger-web(1)
+
+
+
+NAME
+       hledger-web - web interface for the hledger accounting tool
+
+SYNOPSIS
+       hledger-web [OPTIONS]
+       hledger web -- [OPTIONS]
+
+DESCRIPTION
+       hledger  is  a  cross-platform program for tracking money, time, or any
+       other commodity, using double-entry accounting and a  simple,  editable
+       file  format.   hledger  is  inspired  by  and  largely compatible with
+       ledger(1).
+
+       hledger-web is hledger's web interface.  It starts a simple web  appli-
+       cation for browsing and adding transactions, and optionally opens it in
+       a web browser window if possible.  It provides a more user-friendly  UI
+       than  the  hledger  CLI  or  hledger-ui interface, showing more at once
+       (accounts, the current account register, balance charts)  and  allowing
+       history-aware data entry, interactive searching, and bookmarking.
+
+       hledger-web  also  lets you share a ledger with multiple users, or even
+       the public web.  There is no access control, so if you  need  that  you
+       should  put  it  behind  a  suitable  web proxy.  As a small protection
+       against data loss when running an unprotected  instance,  it  writes  a
+       numbered backup of the main journal file (only ?)  on every edit.
+
+       Like  hledger, it reads data from one or more files in hledger journal,
+       timeclock, timedot, or CSV format specified with -f,  or  $LEDGER_FILE,
+       or        $HOME/.hledger.journal       (on       windows,       perhaps
+       C:/Users/USER/.hledger.journal).  For more about this  see  hledger(1),
+       hledger_journal(5) etc.
+
+       By default, hledger-web starts the web app in "transient mode" and also
+       opens it in your default web browser if possible.  In this mode the web
+       app will keep running for as long as you have it open in a browser win-
+       dow, and will exit after two minutes of inactivity (no requests and  no
+       browser  windows  viewing  it).  With --serve, it just runs the web app
+       without exiting, and logs requests to the console.
+
+       By default the server listens on IP address 127.0.0.1, accessible  only
+       to   local   requests.    You   can  use  --host  to  change  this,  eg
+       --host 0.0.0.0 to listen on all configured addresses.
+
+       Similarly, use --port to set a TCP port other than 5000, eg if you  are
+       running multiple hledger-web instances.
+
+       You  can use --base-url to change the protocol, hostname, port and path
+       that appear in hyperlinks, useful eg for integrating hledger-web within
+       a  larger website.  The default is http://HOST:PORT/ using the server's
+       configured host address and TCP port (or http://HOST if PORT is 80).
+
+       With --file-url you can set a different base url for static  files,  eg
+       for better caching or cookie-less serving on high performance websites.
+
+       Note there is no built-in  access  control  (aside  from  listening  on
+       127.0.0.1  by default).  So you will need to hide hledger-web behind an
+       authenticating proxy (such as apache or nginx) if you want to  restrict
+       who can see and add entries to your journal.
+
+       Command-line options and arguments may be used to set an initial filter
+       on the data.  This is not shown in the web UI, but it will  be  applied
+       in addition to any search query entered there.
+
+       With journal and timeclock files (but not CSV files, currently) the web
+       app detects changes made by other means and will show the new  data  on
+       the  next request.  If a change makes the file unparseable, hledger-web
+       will show an error until the file has been fixed.
+
+OPTIONS
+       Note: if invoking hledger-web as a hledger subcommand, write --  before
+       options as shown above.
+
+       --serve
+              serve and log requests, don't browse or auto-exit
+
+       --host=IPADDR
+              listen on this IP address (default: 127.0.0.1)
+
+       --port=PORT
+              listen on this TCP port (default: 5000)
+
+       --base-url=URL
+              set  the  base  url  (default:  http://IPADDR:PORT).   You would
+              change this when sharing over the network, or integrating within
+              a larger website.
+
+       --file-url=URL
+              set the static files url (default: BASEURL/static).  hledger-web
+              normally serves static files itself, but if you wanted to  serve
+              them  from  another server for efficiency, you would set the url
+              with this.
+
+       hledger input options:
+
+       -f FILE --file=FILE
+              use  a  different  input  file.   For  stdin,  use  -  (default:
+              $LEDGER_FILE or $HOME/.hledger.journal)
+
+       --rules-file=RULESFILE
+              Conversion   rules  file  to  use  when  reading  CSV  (default:
+              FILE.rules)
+
+       --alias=OLD=NEW
+              rename accounts named OLD to NEW
+
+       --anon anonymize accounts and payees
+
+       --pivot FIELDNAME
+              use some other field or tag for the account name
+
+       -I --ignore-assertions
+              ignore any failing balance assertions
+
+       hledger reporting options:
+
+       -b --begin=DATE
+              include postings/txns on or after this date
+
+       -e --end=DATE
+              include postings/txns before this date
+
+       -D --daily
+              multiperiod/multicolumn report by day
+
+       -W --weekly
+              multiperiod/multicolumn report by week
+
+       -M --monthly
+              multiperiod/multicolumn report by month
+
+       -Q --quarterly
+              multiperiod/multicolumn report by quarter
+
+       -Y --yearly
+              multiperiod/multicolumn report by year
+
+       -p --period=PERIODEXP
+              set start date, end date, and/or reporting interval all at  once
+              using period expressions syntax (overrides the flags above)
+
+       --date2
+              match  the  secondary  date  instead (see command help for other
+              effects)
+
+       -U --unmarked
+              include only unmarked postings/txns (can combine with -P or -C)
+
+       -P --pending
+              include only pending postings/txns
+
+       -C --cleared
+              include only cleared postings/txns
+
+       -R --real
+              include only non-virtual postings
+
+       -NUM --depth=NUM
+              hide/aggregate accounts or postings more than NUM levels deep
+
+       -E --empty
+              show items with zero amount, normally hidden
+
+       -B --cost
+              convert amounts to their cost at  transaction  time  (using  the
+              transaction price, if any)
+
+       -V --value
+              convert  amounts  to  their  market value on the report end date
+              (using the most recent applicable market price, if any)
+
+       --auto apply automated posting rules to modify transactions.
+
+       --forecast
+              apply periodic transaction rules  to  generate  future  transac-
+              tions, to 6 months from now or report end date.
+
+       When a reporting option appears more than once in the command line, the
+       last one takes precedence.
+
+       Some reporting options can also be written as query arguments.
+
+       hledger help options:
+
+       -h --help
+              show general usage (or after COMMAND, command usage)
+
+       --version
+              show version
+
+       --debug[=N]
+              show debug output (levels 1-9, default: 1)
+
+       A @FILE argument will be expanded to the contents of FILE, which should
+       contain  one  command line option/argument per line.  (To prevent this,
+       insert a -- argument before.)
+
+ENVIRONMENT
+       LEDGER_FILE The journal file path when not specified with -f.  Default:
+       ~/.hledger.journal  (on  windows,  perhaps C:/Users/USER/.hledger.jour-
+       nal).
+
+FILES
+       Reads data from one or more files in hledger journal, timeclock,  time-
+       dot,   or   CSV   format   specified   with  -f,  or  $LEDGER_FILE,  or
+       $HOME/.hledger.journal          (on          windows,           perhaps
+       C:/Users/USER/.hledger.journal).
+
+BUGS
+       The  need  to precede options with -- when invoked from hledger is awk-
+       ward.
+
+       -f- doesn't work (hledger-web can't read from stdin).
+
+       Query arguments and some hledger options are ignored.
+
+       Does not work in text-mode browsers.
+
+       Does not work well on small screens.
+
+
+
+REPORTING BUGS
+       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel
+       or hledger mail list)
+
+
+AUTHORS
+       Simon Michael <simon@joyful.com> and contributors
+
+
+COPYRIGHT
+       Copyright (C) 2007-2016 Simon Michael.
+       Released under GNU GPL v3 or later.
+
+
+SEE ALSO
+       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),
+       hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
+       dot(5), ledger(1)
+
+       http://hledger.org
+
+
+
+hledger-web 1.5                  December 2017                  hledger-web(1)
diff --git a/static/css/bootstrap-datepicker.standalone.min.css b/static/css/bootstrap-datepicker.standalone.min.css
new file mode 100644
--- /dev/null
+++ b/static/css/bootstrap-datepicker.standalone.min.css
@@ -0,0 +1,7 @@
+/*!
+ * Datepicker for Bootstrap v1.7.1 (https://github.com/uxsolutions/bootstrap-datepicker)
+ *
+ * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ */
+
+.datepicker{padding:4px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;direction:ltr}.datepicker-inline{width:220px}.datepicker-rtl{direction:rtl}.datepicker-rtl.dropdown-menu{left:auto}.datepicker-rtl table tr td span{float:right}.datepicker-dropdown{top:0;left:0}.datepicker-dropdown:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #999;border-top:0;border-bottom-color:rgba(0,0,0,.2);position:absolute}.datepicker-dropdown:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;border-top:0;position:absolute}.datepicker-dropdown.datepicker-orient-left:before{left:6px}.datepicker-dropdown.datepicker-orient-left:after{left:7px}.datepicker-dropdown.datepicker-orient-right:before{right:6px}.datepicker-dropdown.datepicker-orient-right:after{right:7px}.datepicker-dropdown.datepicker-orient-bottom:before{top:-7px}.datepicker-dropdown.datepicker-orient-bottom:after{top:-6px}.datepicker-dropdown.datepicker-orient-top:before{bottom:-7px;border-bottom:0;border-top:7px solid #999}.datepicker-dropdown.datepicker-orient-top:after{bottom:-6px;border-bottom:0;border-top:6px solid #fff}.datepicker table{margin:0;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.datepicker td,.datepicker th{text-align:center;width:20px;height:20px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;border:none}.table-striped .datepicker table tr td,.table-striped .datepicker table tr th{background-color:transparent}.datepicker table tr td.day.focused,.datepicker table tr td.day:hover{background:#eee;cursor:pointer}.datepicker table tr td.new,.datepicker table tr td.old{color:#999}.datepicker table tr td.disabled,.datepicker table tr td.disabled:hover{background:0 0;color:#999;cursor:default}.datepicker table tr td.highlighted{background:#d9edf7;border-radius:0}.datepicker table tr td.today,.datepicker table tr td.today.disabled,.datepicker table tr td.today.disabled:hover,.datepicker table tr td.today:hover{background-color:#fde19a;background-image:-moz-linear-gradient(to bottom,#fdd49a,#fdf59a);background-image:-ms-linear-gradient(to bottom,#fdd49a,#fdf59a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fdd49a),to(#fdf59a));background-image:-webkit-linear-gradient(to bottom,#fdd49a,#fdf59a);background-image:-o-linear-gradient(to bottom,#fdd49a,#fdf59a);background-image:linear-gradient(to bottom,#fdd49a,#fdf59a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);border-color:#fdf59a #fdf59a #fbed50;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);color:#000}.datepicker table tr td.today.active,.datepicker table tr td.today.disabled,.datepicker table tr td.today.disabled.active,.datepicker table tr td.today.disabled.disabled,.datepicker table tr td.today.disabled:active,.datepicker table tr td.today.disabled:hover,.datepicker table tr td.today.disabled:hover.active,.datepicker table tr td.today.disabled:hover.disabled,.datepicker table tr td.today.disabled:hover:active,.datepicker table tr td.today.disabled:hover:hover,.datepicker table tr td.today.disabled:hover[disabled],.datepicker table tr td.today.disabled[disabled],.datepicker table tr td.today:active,.datepicker table tr td.today:hover,.datepicker table tr td.today:hover.active,.datepicker table tr td.today:hover.disabled,.datepicker table tr td.today:hover:active,.datepicker table tr td.today:hover:hover,.datepicker table tr td.today:hover[disabled],.datepicker table tr td.today[disabled]{background-color:#fdf59a}.datepicker table tr td.today.active,.datepicker table tr td.today.disabled.active,.datepicker table tr td.today.disabled:active,.datepicker table tr td.today.disabled:hover.active,.datepicker table tr td.today.disabled:hover:active,.datepicker table tr td.today:active,.datepicker table tr td.today:hover.active,.datepicker table tr td.today:hover:active{background-color:#fbf069\9}.datepicker table tr td.today:hover:hover{color:#000}.datepicker table tr td.today.active:hover{color:#fff}.datepicker table tr td.range,.datepicker table tr td.range.disabled,.datepicker table tr td.range.disabled:hover,.datepicker table tr td.range:hover{background:#eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.datepicker table tr td.range.today,.datepicker table tr td.range.today.disabled,.datepicker table tr td.range.today.disabled:hover,.datepicker table tr td.range.today:hover{background-color:#f3d17a;background-image:-moz-linear-gradient(to bottom,#f3c17a,#f3e97a);background-image:-ms-linear-gradient(to bottom,#f3c17a,#f3e97a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f3c17a),to(#f3e97a));background-image:-webkit-linear-gradient(to bottom,#f3c17a,#f3e97a);background-image:-o-linear-gradient(to bottom,#f3c17a,#f3e97a);background-image:linear-gradient(to bottom,#f3c17a,#f3e97a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0);border-color:#f3e97a #f3e97a #edde34;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.datepicker table tr td.range.today.active,.datepicker table tr td.range.today.disabled,.datepicker table tr td.range.today.disabled.active,.datepicker table tr td.range.today.disabled.disabled,.datepicker table tr td.range.today.disabled:active,.datepicker table tr td.range.today.disabled:hover,.datepicker table tr td.range.today.disabled:hover.active,.datepicker table tr td.range.today.disabled:hover.disabled,.datepicker table tr td.range.today.disabled:hover:active,.datepicker table tr td.range.today.disabled:hover:hover,.datepicker table tr td.range.today.disabled:hover[disabled],.datepicker table tr td.range.today.disabled[disabled],.datepicker table tr td.range.today:active,.datepicker table tr td.range.today:hover,.datepicker table tr td.range.today:hover.active,.datepicker table tr td.range.today:hover.disabled,.datepicker table tr td.range.today:hover:active,.datepicker table tr td.range.today:hover:hover,.datepicker table tr td.range.today:hover[disabled],.datepicker table tr td.range.today[disabled]{background-color:#f3e97a}.datepicker table tr td.range.today.active,.datepicker table tr td.range.today.disabled.active,.datepicker table tr td.range.today.disabled:active,.datepicker table tr td.range.today.disabled:hover.active,.datepicker table tr td.range.today.disabled:hover:active,.datepicker table tr td.range.today:active,.datepicker table tr td.range.today:hover.active,.datepicker table tr td.range.today:hover:active{background-color:#efe24b\9}.datepicker table tr td.selected,.datepicker table tr td.selected.disabled,.datepicker table tr td.selected.disabled:hover,.datepicker table tr td.selected:hover{background-color:#9e9e9e;background-image:-moz-linear-gradient(to bottom,#b3b3b3,grey);background-image:-ms-linear-gradient(to bottom,#b3b3b3,grey);background-image:-webkit-gradient(linear,0 0,0 100%,from(#b3b3b3),to(grey));background-image:-webkit-linear-gradient(to bottom,#b3b3b3,grey);background-image:-o-linear-gradient(to bottom,#b3b3b3,grey);background-image:linear-gradient(to bottom,#b3b3b3,grey);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0);border-color:grey grey #595959;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25)}.datepicker table tr td.selected.active,.datepicker table tr td.selected.disabled,.datepicker table tr td.selected.disabled.active,.datepicker table tr td.selected.disabled.disabled,.datepicker table tr td.selected.disabled:active,.datepicker table tr td.selected.disabled:hover,.datepicker table tr td.selected.disabled:hover.active,.datepicker table tr td.selected.disabled:hover.disabled,.datepicker table tr td.selected.disabled:hover:active,.datepicker table tr td.selected.disabled:hover:hover,.datepicker table tr td.selected.disabled:hover[disabled],.datepicker table tr td.selected.disabled[disabled],.datepicker table tr td.selected:active,.datepicker table tr td.selected:hover,.datepicker table tr td.selected:hover.active,.datepicker table tr td.selected:hover.disabled,.datepicker table tr td.selected:hover:active,.datepicker table tr td.selected:hover:hover,.datepicker table tr td.selected:hover[disabled],.datepicker table tr td.selected[disabled]{background-color:grey}.datepicker table tr td.selected.active,.datepicker table tr td.selected.disabled.active,.datepicker table tr td.selected.disabled:active,.datepicker table tr td.selected.disabled:hover.active,.datepicker table tr td.selected.disabled:hover:active,.datepicker table tr td.selected:active,.datepicker table tr td.selected:hover.active,.datepicker table tr td.selected:hover:active{background-color:#666\9}.datepicker table tr td.active,.datepicker table tr td.active.disabled,.datepicker table tr td.active.disabled:hover,.datepicker table tr td.active:hover{background-color:#006dcc;background-image:-moz-linear-gradient(to bottom,#08c,#04c);background-image:-ms-linear-gradient(to bottom,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(to bottom,#08c,#04c);background-image:-o-linear-gradient(to bottom,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#08c', endColorstr='#0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25)}.datepicker table tr td.active.active,.datepicker table tr td.active.disabled,.datepicker table tr td.active.disabled.active,.datepicker table tr td.active.disabled.disabled,.datepicker table tr td.active.disabled:active,.datepicker table tr td.active.disabled:hover,.datepicker table tr td.active.disabled:hover.active,.datepicker table tr td.active.disabled:hover.disabled,.datepicker table tr td.active.disabled:hover:active,.datepicker table tr td.active.disabled:hover:hover,.datepicker table tr td.active.disabled:hover[disabled],.datepicker table tr td.active.disabled[disabled],.datepicker table tr td.active:active,.datepicker table tr td.active:hover,.datepicker table tr td.active:hover.active,.datepicker table tr td.active:hover.disabled,.datepicker table tr td.active:hover:active,.datepicker table tr td.active:hover:hover,.datepicker table tr td.active:hover[disabled],.datepicker table tr td.active[disabled]{background-color:#04c}.datepicker table tr td.active.active,.datepicker table tr td.active.disabled.active,.datepicker table tr td.active.disabled:active,.datepicker table tr td.active.disabled:hover.active,.datepicker table tr td.active.disabled:hover:active,.datepicker table tr td.active:active,.datepicker table tr td.active:hover.active,.datepicker table tr td.active:hover:active{background-color:#039\9}.datepicker table tr td span{display:block;width:23%;height:54px;line-height:54px;float:left;margin:1%;cursor:pointer;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.datepicker table tr td span.focused,.datepicker table tr td span:hover{background:#eee}.datepicker table tr td span.disabled,.datepicker table tr td span.disabled:hover{background:0 0;color:#999;cursor:default}.datepicker table tr td span.active,.datepicker table tr td span.active.disabled,.datepicker table tr td span.active.disabled:hover,.datepicker table tr td span.active:hover{background-color:#006dcc;background-image:-moz-linear-gradient(to bottom,#08c,#04c);background-image:-ms-linear-gradient(to bottom,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(to bottom,#08c,#04c);background-image:-o-linear-gradient(to bottom,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#08c', endColorstr='#0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25)}.datepicker table tr td span.active.active,.datepicker table tr td span.active.disabled,.datepicker table tr td span.active.disabled.active,.datepicker table tr td span.active.disabled.disabled,.datepicker table tr td span.active.disabled:active,.datepicker table tr td span.active.disabled:hover,.datepicker table tr td span.active.disabled:hover.active,.datepicker table tr td span.active.disabled:hover.disabled,.datepicker table tr td span.active.disabled:hover:active,.datepicker table tr td span.active.disabled:hover:hover,.datepicker table tr td span.active.disabled:hover[disabled],.datepicker table tr td span.active.disabled[disabled],.datepicker table tr td span.active:active,.datepicker table tr td span.active:hover,.datepicker table tr td span.active:hover.active,.datepicker table tr td span.active:hover.disabled,.datepicker table tr td span.active:hover:active,.datepicker table tr td span.active:hover:hover,.datepicker table tr td span.active:hover[disabled],.datepicker table tr td span.active[disabled]{background-color:#04c}.datepicker table tr td span.active.active,.datepicker table tr td span.active.disabled.active,.datepicker table tr td span.active.disabled:active,.datepicker table tr td span.active.disabled:hover.active,.datepicker table tr td span.active.disabled:hover:active,.datepicker table tr td span.active:active,.datepicker table tr td span.active:hover.active,.datepicker table tr td span.active:hover:active{background-color:#039\9}.datepicker table tr td span.new,.datepicker table tr td span.old{color:#999}.datepicker .datepicker-switch{width:145px}.datepicker .datepicker-switch,.datepicker .next,.datepicker .prev,.datepicker tfoot tr th{cursor:pointer}.datepicker .datepicker-switch:hover,.datepicker .next:hover,.datepicker .prev:hover,.datepicker tfoot tr th:hover{background:#eee}.datepicker .next.disabled,.datepicker .prev.disabled{visibility:hidden}.datepicker .cw{font-size:10px;width:12px;padding:0 2px 0 5px;vertical-align:middle}.input-append.date .add-on,.input-prepend.date .add-on{cursor:pointer}.input-append.date .add-on i,.input-prepend.date .add-on i{margin-top:3px}.input-daterange input{text-align:center}.input-daterange input:first-child{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-daterange input:last-child{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-daterange .add-on{display:inline-block;width:auto;min-width:16px;height:20px;padding:4px 5px;font-weight:400;line-height:20px;text-align:center;text-shadow:0 1px 0 #fff;vertical-align:middle;background-color:#eee;border:1px solid #ccc;margin-left:-5px;margin-right:-5px}.datepicker.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;float:left;display:none;min-width:160px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;*border-right-width:2px;*border-bottom-width:2px;color:#333;font-size:13px;line-height:20px}.datepicker.datepicker-inline td,.datepicker.datepicker-inline th,.datepicker.dropdown-menu td,.datepicker.dropdown-menu th{padding:4px 5px}
diff --git a/static/hledger.css b/static/hledger.css
--- a/static/hledger.css
+++ b/static/hledger.css
@@ -201,7 +201,7 @@
 }
 
 #main-content {
-   /* 
+   /*
     -webkit-transition: width 0.3s ease, margin 0.3s ease;
     -moz-transition: width 0.3s ease, margin 0.3s ease;
     -o-transition: width 0.3s ease, margin 0.3s ease;
diff --git a/static/hledger.js b/static/hledger.js
--- a/static/hledger.js
+++ b/static/hledger.js
@@ -4,16 +4,31 @@
 // STARTUP
 
 $(document).ready(function() {
+  // cache the input element as a variable
+  // for minor performance   benefits
+  var dateEl = $('#dateWrap');
 
-  // ensure add form always focusses its first field
+  // ensure add form always focuses its first field
   $('#addmodal')
-    .on('shown.bs.modal', function (e) {
+    .on('shown.bs.modal', function() {
       addformFocus();
     })
+    .on('hidden.bs.modal', function() {
+      // close the date picker if open
+      dateEl.datepicker('hide');
+    });
 
   // show add form if ?add=1
   if ($.url.param('add')) { addformShow(true); }
 
+  // date picker
+  // http://bootstrap-datepicker.readthedocs.io/en/latest/options.html
+  dateEl.datepicker({
+    showOnFocus: false,
+    autoclose: true,
+    format: 'yyyy-mm-dd'
+  });
+
   // sidebar account hover handlers
   $('#sidebar td a').mouseenter(function(){ $(this).parent().addClass('mouseover'); });
   $('#sidebar td').mouseleave(function(){ $(this).removeClass('mouseover'); });
@@ -37,7 +52,7 @@
   if (window.location.hash && $(window.location.hash)[0]) {
     $(window.location.hash).addClass('highlighted');
   }
-  $(window).on('hashchange', function(event) {
+  $(window).on('hashchange', function() {
     $('.highlighted').removeClass('highlighted');
     $(window.location.hash).addClass('highlighted');
   });
@@ -49,6 +64,7 @@
 //----------------------------------------------------------------------
 // REGISTER CHART
 
+//eslint-disable-next-line no-unused-vars
 function registerChart($container, series) {
   // https://github.com/flot/flot/blob/master/API.md
   return $container.plot(
@@ -141,7 +157,6 @@
     // reset typehead state (though not fetched completions)
     $('.typeahead').typeahead('val', '');
     $('.tt-dropdown-menu').hide();
-    $('input#date').val(''); // #322 don't set a default, typeahead(?) clears it on tab. See also Foundation.hs
   }
 }
 
diff --git a/static/js/bootstrap-datepicker.min.js b/static/js/bootstrap-datepicker.min.js
new file mode 100644
--- /dev/null
+++ b/static/js/bootstrap-datepicker.min.js
@@ -0,0 +1,8 @@
+/*!
+ * Datepicker for Bootstrap v1.7.1 (https://github.com/uxsolutions/bootstrap-datepicker)
+ *
+ * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ */
+
+!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a,b){function c(){return new Date(Date.UTC.apply(Date,arguments))}function d(){var a=new Date;return c(a.getFullYear(),a.getMonth(),a.getDate())}function e(a,b){return a.getUTCFullYear()===b.getUTCFullYear()&&a.getUTCMonth()===b.getUTCMonth()&&a.getUTCDate()===b.getUTCDate()}function f(c,d){return function(){return d!==b&&a.fn.datepicker.deprecated(d),this[c].apply(this,arguments)}}function g(a){return a&&!isNaN(a.getTime())}function h(b,c){function d(a,b){return b.toLowerCase()}var e,f=a(b).data(),g={},h=new RegExp("^"+c.toLowerCase()+"([A-Z])");c=new RegExp("^"+c.toLowerCase());for(var i in f)c.test(i)&&(e=i.replace(h,d),g[e]=f[i]);return g}function i(b){var c={};if(q[b]||(b=b.split("-")[0],q[b])){var d=q[b];return a.each(p,function(a,b){b in d&&(c[b]=d[b])}),c}}var j=function(){var b={get:function(a){return this.slice(a)[0]},contains:function(a){for(var b=a&&a.valueOf(),c=0,d=this.length;c<d;c++)if(0<=this[c].valueOf()-b&&this[c].valueOf()-b<864e5)return c;return-1},remove:function(a){this.splice(a,1)},replace:function(b){b&&(a.isArray(b)||(b=[b]),this.clear(),this.push.apply(this,b))},clear:function(){this.length=0},copy:function(){var a=new j;return a.replace(this),a}};return function(){var c=[];return c.push.apply(c,arguments),a.extend(c,b),c}}(),k=function(b,c){a.data(b,"datepicker",this),this._process_options(c),this.dates=new j,this.viewDate=this.o.defaultViewDate,this.focusDate=null,this.element=a(b),this.isInput=this.element.is("input"),this.inputField=this.isInput?this.element:this.element.find("input"),this.component=!!this.element.hasClass("date")&&this.element.find(".add-on, .input-group-addon, .btn"),this.component&&0===this.component.length&&(this.component=!1),this.isInline=!this.component&&this.element.is("div"),this.picker=a(r.template),this._check_template(this.o.templates.leftArrow)&&this.picker.find(".prev").html(this.o.templates.leftArrow),this._check_template(this.o.templates.rightArrow)&&this.picker.find(".next").html(this.o.templates.rightArrow),this._buildEvents(),this._attachEvents(),this.isInline?this.picker.addClass("datepicker-inline").appendTo(this.element):this.picker.addClass("datepicker-dropdown dropdown-menu"),this.o.rtl&&this.picker.addClass("datepicker-rtl"),this.o.calendarWeeks&&this.picker.find(".datepicker-days .datepicker-switch, thead .datepicker-title, tfoot .today, tfoot .clear").attr("colspan",function(a,b){return Number(b)+1}),this._process_options({startDate:this._o.startDate,endDate:this._o.endDate,daysOfWeekDisabled:this.o.daysOfWeekDisabled,daysOfWeekHighlighted:this.o.daysOfWeekHighlighted,datesDisabled:this.o.datesDisabled}),this._allow_update=!1,this.setViewMode(this.o.startView),this._allow_update=!0,this.fillDow(),this.fillMonths(),this.update(),this.isInline&&this.show()};k.prototype={constructor:k,_resolveViewName:function(b){return a.each(r.viewModes,function(c,d){if(b===c||a.inArray(b,d.names)!==-1)return b=c,!1}),b},_resolveDaysOfWeek:function(b){return a.isArray(b)||(b=b.split(/[,\s]*/)),a.map(b,Number)},_check_template:function(c){try{if(c===b||""===c)return!1;if((c.match(/[<>]/g)||[]).length<=0)return!0;var d=a(c);return d.length>0}catch(a){return!1}},_process_options:function(b){this._o=a.extend({},this._o,b);var e=this.o=a.extend({},this._o),f=e.language;q[f]||(f=f.split("-")[0],q[f]||(f=o.language)),e.language=f,e.startView=this._resolveViewName(e.startView),e.minViewMode=this._resolveViewName(e.minViewMode),e.maxViewMode=this._resolveViewName(e.maxViewMode),e.startView=Math.max(this.o.minViewMode,Math.min(this.o.maxViewMode,e.startView)),e.multidate!==!0&&(e.multidate=Number(e.multidate)||!1,e.multidate!==!1&&(e.multidate=Math.max(0,e.multidate))),e.multidateSeparator=String(e.multidateSeparator),e.weekStart%=7,e.weekEnd=(e.weekStart+6)%7;var g=r.parseFormat(e.format);e.startDate!==-(1/0)&&(e.startDate?e.startDate instanceof Date?e.startDate=this._local_to_utc(this._zero_time(e.startDate)):e.startDate=r.parseDate(e.startDate,g,e.language,e.assumeNearbyYear):e.startDate=-(1/0)),e.endDate!==1/0&&(e.endDate?e.endDate instanceof Date?e.endDate=this._local_to_utc(this._zero_time(e.endDate)):e.endDate=r.parseDate(e.endDate,g,e.language,e.assumeNearbyYear):e.endDate=1/0),e.daysOfWeekDisabled=this._resolveDaysOfWeek(e.daysOfWeekDisabled||[]),e.daysOfWeekHighlighted=this._resolveDaysOfWeek(e.daysOfWeekHighlighted||[]),e.datesDisabled=e.datesDisabled||[],a.isArray(e.datesDisabled)||(e.datesDisabled=e.datesDisabled.split(",")),e.datesDisabled=a.map(e.datesDisabled,function(a){return r.parseDate(a,g,e.language,e.assumeNearbyYear)});var h=String(e.orientation).toLowerCase().split(/\s+/g),i=e.orientation.toLowerCase();if(h=a.grep(h,function(a){return/^auto|left|right|top|bottom$/.test(a)}),e.orientation={x:"auto",y:"auto"},i&&"auto"!==i)if(1===h.length)switch(h[0]){case"top":case"bottom":e.orientation.y=h[0];break;case"left":case"right":e.orientation.x=h[0]}else i=a.grep(h,function(a){return/^left|right$/.test(a)}),e.orientation.x=i[0]||"auto",i=a.grep(h,function(a){return/^top|bottom$/.test(a)}),e.orientation.y=i[0]||"auto";else;if(e.defaultViewDate instanceof Date||"string"==typeof e.defaultViewDate)e.defaultViewDate=r.parseDate(e.defaultViewDate,g,e.language,e.assumeNearbyYear);else if(e.defaultViewDate){var j=e.defaultViewDate.year||(new Date).getFullYear(),k=e.defaultViewDate.month||0,l=e.defaultViewDate.day||1;e.defaultViewDate=c(j,k,l)}else e.defaultViewDate=d()},_events:[],_secondaryEvents:[],_applyEvents:function(a){for(var c,d,e,f=0;f<a.length;f++)c=a[f][0],2===a[f].length?(d=b,e=a[f][1]):3===a[f].length&&(d=a[f][1],e=a[f][2]),c.on(e,d)},_unapplyEvents:function(a){for(var c,d,e,f=0;f<a.length;f++)c=a[f][0],2===a[f].length?(e=b,d=a[f][1]):3===a[f].length&&(e=a[f][1],d=a[f][2]),c.off(d,e)},_buildEvents:function(){var b={keyup:a.proxy(function(b){a.inArray(b.keyCode,[27,37,39,38,40,32,13,9])===-1&&this.update()},this),keydown:a.proxy(this.keydown,this),paste:a.proxy(this.paste,this)};this.o.showOnFocus===!0&&(b.focus=a.proxy(this.show,this)),this.isInput?this._events=[[this.element,b]]:this.component&&this.inputField.length?this._events=[[this.inputField,b],[this.component,{click:a.proxy(this.show,this)}]]:this._events=[[this.element,{click:a.proxy(this.show,this),keydown:a.proxy(this.keydown,this)}]],this._events.push([this.element,"*",{blur:a.proxy(function(a){this._focused_from=a.target},this)}],[this.element,{blur:a.proxy(function(a){this._focused_from=a.target},this)}]),this.o.immediateUpdates&&this._events.push([this.element,{"changeYear changeMonth":a.proxy(function(a){this.update(a.date)},this)}]),this._secondaryEvents=[[this.picker,{click:a.proxy(this.click,this)}],[this.picker,".prev, .next",{click:a.proxy(this.navArrowsClick,this)}],[this.picker,".day:not(.disabled)",{click:a.proxy(this.dayCellClick,this)}],[a(window),{resize:a.proxy(this.place,this)}],[a(document),{"mousedown touchstart":a.proxy(function(a){this.element.is(a.target)||this.element.find(a.target).length||this.picker.is(a.target)||this.picker.find(a.target).length||this.isInline||this.hide()},this)}]]},_attachEvents:function(){this._detachEvents(),this._applyEvents(this._events)},_detachEvents:function(){this._unapplyEvents(this._events)},_attachSecondaryEvents:function(){this._detachSecondaryEvents(),this._applyEvents(this._secondaryEvents)},_detachSecondaryEvents:function(){this._unapplyEvents(this._secondaryEvents)},_trigger:function(b,c){var d=c||this.dates.get(-1),e=this._utc_to_local(d);this.element.trigger({type:b,date:e,viewMode:this.viewMode,dates:a.map(this.dates,this._utc_to_local),format:a.proxy(function(a,b){0===arguments.length?(a=this.dates.length-1,b=this.o.format):"string"==typeof a&&(b=a,a=this.dates.length-1),b=b||this.o.format;var c=this.dates.get(a);return r.formatDate(c,b,this.o.language)},this)})},show:function(){if(!(this.inputField.prop("disabled")||this.inputField.prop("readonly")&&this.o.enableOnReadonly===!1))return this.isInline||this.picker.appendTo(this.o.container),this.place(),this.picker.show(),this._attachSecondaryEvents(),this._trigger("show"),(window.navigator.msMaxTouchPoints||"ontouchstart"in document)&&this.o.disableTouchKeyboard&&a(this.element).blur(),this},hide:function(){return this.isInline||!this.picker.is(":visible")?this:(this.focusDate=null,this.picker.hide().detach(),this._detachSecondaryEvents(),this.setViewMode(this.o.startView),this.o.forceParse&&this.inputField.val()&&this.setValue(),this._trigger("hide"),this)},destroy:function(){return this.hide(),this._detachEvents(),this._detachSecondaryEvents(),this.picker.remove(),delete this.element.data().datepicker,this.isInput||delete this.element.data().date,this},paste:function(b){var c;if(b.originalEvent.clipboardData&&b.originalEvent.clipboardData.types&&a.inArray("text/plain",b.originalEvent.clipboardData.types)!==-1)c=b.originalEvent.clipboardData.getData("text/plain");else{if(!window.clipboardData)return;c=window.clipboardData.getData("Text")}this.setDate(c),this.update(),b.preventDefault()},_utc_to_local:function(a){if(!a)return a;var b=new Date(a.getTime()+6e4*a.getTimezoneOffset());return b.getTimezoneOffset()!==a.getTimezoneOffset()&&(b=new Date(a.getTime()+6e4*b.getTimezoneOffset())),b},_local_to_utc:function(a){return a&&new Date(a.getTime()-6e4*a.getTimezoneOffset())},_zero_time:function(a){return a&&new Date(a.getFullYear(),a.getMonth(),a.getDate())},_zero_utc_time:function(a){return a&&c(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())},getDates:function(){return a.map(this.dates,this._utc_to_local)},getUTCDates:function(){return a.map(this.dates,function(a){return new Date(a)})},getDate:function(){return this._utc_to_local(this.getUTCDate())},getUTCDate:function(){var a=this.dates.get(-1);return a!==b?new Date(a):null},clearDates:function(){this.inputField.val(""),this.update(),this._trigger("changeDate"),this.o.autoclose&&this.hide()},setDates:function(){var b=a.isArray(arguments[0])?arguments[0]:arguments;return this.update.apply(this,b),this._trigger("changeDate"),this.setValue(),this},setUTCDates:function(){var b=a.isArray(arguments[0])?arguments[0]:arguments;return this.setDates.apply(this,a.map(b,this._utc_to_local)),this},setDate:f("setDates"),setUTCDate:f("setUTCDates"),remove:f("destroy","Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead"),setValue:function(){var a=this.getFormattedDate();return this.inputField.val(a),this},getFormattedDate:function(c){c===b&&(c=this.o.format);var d=this.o.language;return a.map(this.dates,function(a){return r.formatDate(a,c,d)}).join(this.o.multidateSeparator)},getStartDate:function(){return this.o.startDate},setStartDate:function(a){return this._process_options({startDate:a}),this.update(),this.updateNavArrows(),this},getEndDate:function(){return this.o.endDate},setEndDate:function(a){return this._process_options({endDate:a}),this.update(),this.updateNavArrows(),this},setDaysOfWeekDisabled:function(a){return this._process_options({daysOfWeekDisabled:a}),this.update(),this},setDaysOfWeekHighlighted:function(a){return this._process_options({daysOfWeekHighlighted:a}),this.update(),this},setDatesDisabled:function(a){return this._process_options({datesDisabled:a}),this.update(),this},place:function(){if(this.isInline)return this;var b=this.picker.outerWidth(),c=this.picker.outerHeight(),d=10,e=a(this.o.container),f=e.width(),g="body"===this.o.container?a(document).scrollTop():e.scrollTop(),h=e.offset(),i=[0];this.element.parents().each(function(){var b=a(this).css("z-index");"auto"!==b&&0!==Number(b)&&i.push(Number(b))});var j=Math.max.apply(Math,i)+this.o.zIndexOffset,k=this.component?this.component.parent().offset():this.element.offset(),l=this.component?this.component.outerHeight(!0):this.element.outerHeight(!1),m=this.component?this.component.outerWidth(!0):this.element.outerWidth(!1),n=k.left-h.left,o=k.top-h.top;"body"!==this.o.container&&(o+=g),this.picker.removeClass("datepicker-orient-top datepicker-orient-bottom datepicker-orient-right datepicker-orient-left"),"auto"!==this.o.orientation.x?(this.picker.addClass("datepicker-orient-"+this.o.orientation.x),"right"===this.o.orientation.x&&(n-=b-m)):k.left<0?(this.picker.addClass("datepicker-orient-left"),n-=k.left-d):n+b>f?(this.picker.addClass("datepicker-orient-right"),n+=m-b):this.o.rtl?this.picker.addClass("datepicker-orient-right"):this.picker.addClass("datepicker-orient-left");var p,q=this.o.orientation.y;if("auto"===q&&(p=-g+o-c,q=p<0?"bottom":"top"),this.picker.addClass("datepicker-orient-"+q),"top"===q?o-=c+parseInt(this.picker.css("padding-top")):o+=l,this.o.rtl){var r=f-(n+m);this.picker.css({top:o,right:r,zIndex:j})}else this.picker.css({top:o,left:n,zIndex:j});return this},_allow_update:!0,update:function(){if(!this._allow_update)return this;var b=this.dates.copy(),c=[],d=!1;return arguments.length?(a.each(arguments,a.proxy(function(a,b){b instanceof Date&&(b=this._local_to_utc(b)),c.push(b)},this)),d=!0):(c=this.isInput?this.element.val():this.element.data("date")||this.inputField.val(),c=c&&this.o.multidate?c.split(this.o.multidateSeparator):[c],delete this.element.data().date),c=a.map(c,a.proxy(function(a){return r.parseDate(a,this.o.format,this.o.language,this.o.assumeNearbyYear)},this)),c=a.grep(c,a.proxy(function(a){return!this.dateWithinRange(a)||!a},this),!0),this.dates.replace(c),this.o.updateViewDate&&(this.dates.length?this.viewDate=new Date(this.dates.get(-1)):this.viewDate<this.o.startDate?this.viewDate=new Date(this.o.startDate):this.viewDate>this.o.endDate?this.viewDate=new Date(this.o.endDate):this.viewDate=this.o.defaultViewDate),d?(this.setValue(),this.element.change()):this.dates.length&&String(b)!==String(this.dates)&&d&&(this._trigger("changeDate"),this.element.change()),!this.dates.length&&b.length&&(this._trigger("clearDate"),this.element.change()),this.fill(),this},fillDow:function(){if(this.o.showWeekDays){var b=this.o.weekStart,c="<tr>";for(this.o.calendarWeeks&&(c+='<th class="cw">&#160;</th>');b<this.o.weekStart+7;)c+='<th class="dow',a.inArray(b,this.o.daysOfWeekDisabled)!==-1&&(c+=" disabled"),c+='">'+q[this.o.language].daysMin[b++%7]+"</th>";c+="</tr>",this.picker.find(".datepicker-days thead").append(c)}},fillMonths:function(){for(var a,b=this._utc_to_local(this.viewDate),c="",d=0;d<12;d++)a=b&&b.getMonth()===d?" focused":"",c+='<span class="month'+a+'">'+q[this.o.language].monthsShort[d]+"</span>";this.picker.find(".datepicker-months td").html(c)},setRange:function(b){b&&b.length?this.range=a.map(b,function(a){return a.valueOf()}):delete this.range,this.fill()},getClassNames:function(b){var c=[],f=this.viewDate.getUTCFullYear(),g=this.viewDate.getUTCMonth(),h=d();return b.getUTCFullYear()<f||b.getUTCFullYear()===f&&b.getUTCMonth()<g?c.push("old"):(b.getUTCFullYear()>f||b.getUTCFullYear()===f&&b.getUTCMonth()>g)&&c.push("new"),this.focusDate&&b.valueOf()===this.focusDate.valueOf()&&c.push("focused"),this.o.todayHighlight&&e(b,h)&&c.push("today"),this.dates.contains(b)!==-1&&c.push("active"),this.dateWithinRange(b)||c.push("disabled"),this.dateIsDisabled(b)&&c.push("disabled","disabled-date"),a.inArray(b.getUTCDay(),this.o.daysOfWeekHighlighted)!==-1&&c.push("highlighted"),this.range&&(b>this.range[0]&&b<this.range[this.range.length-1]&&c.push("range"),a.inArray(b.valueOf(),this.range)!==-1&&c.push("selected"),b.valueOf()===this.range[0]&&c.push("range-start"),b.valueOf()===this.range[this.range.length-1]&&c.push("range-end")),c},_fill_yearsView:function(c,d,e,f,g,h,i){for(var j,k,l,m="",n=e/10,o=this.picker.find(c),p=Math.floor(f/e)*e,q=p+9*n,r=Math.floor(this.viewDate.getFullYear()/n)*n,s=a.map(this.dates,function(a){return Math.floor(a.getUTCFullYear()/n)*n}),t=p-n;t<=q+n;t+=n)j=[d],k=null,t===p-n?j.push("old"):t===q+n&&j.push("new"),a.inArray(t,s)!==-1&&j.push("active"),(t<g||t>h)&&j.push("disabled"),t===r&&j.push("focused"),i!==a.noop&&(l=i(new Date(t,0,1)),l===b?l={}:"boolean"==typeof l?l={enabled:l}:"string"==typeof l&&(l={classes:l}),l.enabled===!1&&j.push("disabled"),l.classes&&(j=j.concat(l.classes.split(/\s+/))),l.tooltip&&(k=l.tooltip)),m+='<span class="'+j.join(" ")+'"'+(k?' title="'+k+'"':"")+">"+t+"</span>";o.find(".datepicker-switch").text(p+"-"+q),o.find("td").html(m)},fill:function(){var d,e,f=new Date(this.viewDate),g=f.getUTCFullYear(),h=f.getUTCMonth(),i=this.o.startDate!==-(1/0)?this.o.startDate.getUTCFullYear():-(1/0),j=this.o.startDate!==-(1/0)?this.o.startDate.getUTCMonth():-(1/0),k=this.o.endDate!==1/0?this.o.endDate.getUTCFullYear():1/0,l=this.o.endDate!==1/0?this.o.endDate.getUTCMonth():1/0,m=q[this.o.language].today||q.en.today||"",n=q[this.o.language].clear||q.en.clear||"",o=q[this.o.language].titleFormat||q.en.titleFormat;if(!isNaN(g)&&!isNaN(h)){this.picker.find(".datepicker-days .datepicker-switch").text(r.formatDate(f,o,this.o.language)),this.picker.find("tfoot .today").text(m).css("display",this.o.todayBtn===!0||"linked"===this.o.todayBtn?"table-cell":"none"),this.picker.find("tfoot .clear").text(n).css("display",this.o.clearBtn===!0?"table-cell":"none"),this.picker.find("thead .datepicker-title").text(this.o.title).css("display","string"==typeof this.o.title&&""!==this.o.title?"table-cell":"none"),this.updateNavArrows(),this.fillMonths();var p=c(g,h,0),s=p.getUTCDate();p.setUTCDate(s-(p.getUTCDay()-this.o.weekStart+7)%7);var t=new Date(p);p.getUTCFullYear()<100&&t.setUTCFullYear(p.getUTCFullYear()),t.setUTCDate(t.getUTCDate()+42),t=t.valueOf();for(var u,v,w=[];p.valueOf()<t;){if(u=p.getUTCDay(),u===this.o.weekStart&&(w.push("<tr>"),this.o.calendarWeeks)){var x=new Date(+p+(this.o.weekStart-u-7)%7*864e5),y=new Date(Number(x)+(11-x.getUTCDay())%7*864e5),z=new Date(Number(z=c(y.getUTCFullYear(),0,1))+(11-z.getUTCDay())%7*864e5),A=(y-z)/864e5/7+1;w.push('<td class="cw">'+A+"</td>")}v=this.getClassNames(p),v.push("day");var B=p.getUTCDate();this.o.beforeShowDay!==a.noop&&(e=this.o.beforeShowDay(this._utc_to_local(p)),e===b?e={}:"boolean"==typeof e?e={enabled:e}:"string"==typeof e&&(e={classes:e}),e.enabled===!1&&v.push("disabled"),e.classes&&(v=v.concat(e.classes.split(/\s+/))),e.tooltip&&(d=e.tooltip),e.content&&(B=e.content)),v=a.isFunction(a.uniqueSort)?a.uniqueSort(v):a.unique(v),w.push('<td class="'+v.join(" ")+'"'+(d?' title="'+d+'"':"")+' data-date="'+p.getTime().toString()+'">'+B+"</td>"),d=null,u===this.o.weekEnd&&w.push("</tr>"),p.setUTCDate(p.getUTCDate()+1)}this.picker.find(".datepicker-days tbody").html(w.join(""));var C=q[this.o.language].monthsTitle||q.en.monthsTitle||"Months",D=this.picker.find(".datepicker-months").find(".datepicker-switch").text(this.o.maxViewMode<2?C:g).end().find("tbody span").removeClass("active");if(a.each(this.dates,function(a,b){b.getUTCFullYear()===g&&D.eq(b.getUTCMonth()).addClass("active")}),(g<i||g>k)&&D.addClass("disabled"),g===i&&D.slice(0,j).addClass("disabled"),g===k&&D.slice(l+1).addClass("disabled"),this.o.beforeShowMonth!==a.noop){var E=this;a.each(D,function(c,d){var e=new Date(g,c,1),f=E.o.beforeShowMonth(e);f===b?f={}:"boolean"==typeof f?f={enabled:f}:"string"==typeof f&&(f={classes:f}),f.enabled!==!1||a(d).hasClass("disabled")||a(d).addClass("disabled"),f.classes&&a(d).addClass(f.classes),f.tooltip&&a(d).prop("title",f.tooltip)})}this._fill_yearsView(".datepicker-years","year",10,g,i,k,this.o.beforeShowYear),this._fill_yearsView(".datepicker-decades","decade",100,g,i,k,this.o.beforeShowDecade),this._fill_yearsView(".datepicker-centuries","century",1e3,g,i,k,this.o.beforeShowCentury)}},updateNavArrows:function(){if(this._allow_update){var a,b,c=new Date(this.viewDate),d=c.getUTCFullYear(),e=c.getUTCMonth(),f=this.o.startDate!==-(1/0)?this.o.startDate.getUTCFullYear():-(1/0),g=this.o.startDate!==-(1/0)?this.o.startDate.getUTCMonth():-(1/0),h=this.o.endDate!==1/0?this.o.endDate.getUTCFullYear():1/0,i=this.o.endDate!==1/0?this.o.endDate.getUTCMonth():1/0,j=1;switch(this.viewMode){case 0:a=d<=f&&e<=g,b=d>=h&&e>=i;break;case 4:j*=10;case 3:j*=10;case 2:j*=10;case 1:a=Math.floor(d/j)*j<=f,b=Math.floor(d/j)*j+j>=h}this.picker.find(".prev").toggleClass("disabled",a),this.picker.find(".next").toggleClass("disabled",b)}},click:function(b){b.preventDefault(),b.stopPropagation();var e,f,g,h;e=a(b.target),e.hasClass("datepicker-switch")&&this.viewMode!==this.o.maxViewMode&&this.setViewMode(this.viewMode+1),e.hasClass("today")&&!e.hasClass("day")&&(this.setViewMode(0),this._setDate(d(),"linked"===this.o.todayBtn?null:"view")),e.hasClass("clear")&&this.clearDates(),e.hasClass("disabled")||(e.hasClass("month")||e.hasClass("year")||e.hasClass("decade")||e.hasClass("century"))&&(this.viewDate.setUTCDate(1),f=1,1===this.viewMode?(h=e.parent().find("span").index(e),g=this.viewDate.getUTCFullYear(),this.viewDate.setUTCMonth(h)):(h=0,g=Number(e.text()),this.viewDate.setUTCFullYear(g)),this._trigger(r.viewModes[this.viewMode-1].e,this.viewDate),this.viewMode===this.o.minViewMode?this._setDate(c(g,h,f)):(this.setViewMode(this.viewMode-1),this.fill())),this.picker.is(":visible")&&this._focused_from&&this._focused_from.focus(),delete this._focused_from},dayCellClick:function(b){var c=a(b.currentTarget),d=c.data("date"),e=new Date(d);this.o.updateViewDate&&(e.getUTCFullYear()!==this.viewDate.getUTCFullYear()&&this._trigger("changeYear",this.viewDate),e.getUTCMonth()!==this.viewDate.getUTCMonth()&&this._trigger("changeMonth",this.viewDate)),this._setDate(e)},navArrowsClick:function(b){var c=a(b.currentTarget),d=c.hasClass("prev")?-1:1;0!==this.viewMode&&(d*=12*r.viewModes[this.viewMode].navStep),this.viewDate=this.moveMonth(this.viewDate,d),this._trigger(r.viewModes[this.viewMode].e,this.viewDate),this.fill()},_toggle_multidate:function(a){var b=this.dates.contains(a);if(a||this.dates.clear(),b!==-1?(this.o.multidate===!0||this.o.multidate>1||this.o.toggleActive)&&this.dates.remove(b):this.o.multidate===!1?(this.dates.clear(),this.dates.push(a)):this.dates.push(a),"number"==typeof this.o.multidate)for(;this.dates.length>this.o.multidate;)this.dates.remove(0)},_setDate:function(a,b){b&&"date"!==b||this._toggle_multidate(a&&new Date(a)),(!b&&this.o.updateViewDate||"view"===b)&&(this.viewDate=a&&new Date(a)),this.fill(),this.setValue(),b&&"view"===b||this._trigger("changeDate"),this.inputField.trigger("change"),!this.o.autoclose||b&&"date"!==b||this.hide()},moveDay:function(a,b){var c=new Date(a);return c.setUTCDate(a.getUTCDate()+b),c},moveWeek:function(a,b){return this.moveDay(a,7*b)},moveMonth:function(a,b){if(!g(a))return this.o.defaultViewDate;if(!b)return a;var c,d,e=new Date(a.valueOf()),f=e.getUTCDate(),h=e.getUTCMonth(),i=Math.abs(b);if(b=b>0?1:-1,1===i)d=b===-1?function(){return e.getUTCMonth()===h}:function(){return e.getUTCMonth()!==c},c=h+b,e.setUTCMonth(c),c=(c+12)%12;else{for(var j=0;j<i;j++)e=this.moveMonth(e,b);c=e.getUTCMonth(),e.setUTCDate(f),d=function(){return c!==e.getUTCMonth()}}for(;d();)e.setUTCDate(--f),e.setUTCMonth(c);return e},moveYear:function(a,b){return this.moveMonth(a,12*b)},moveAvailableDate:function(a,b,c){do{if(a=this[c](a,b),!this.dateWithinRange(a))return!1;c="moveDay"}while(this.dateIsDisabled(a));return a},weekOfDateIsDisabled:function(b){return a.inArray(b.getUTCDay(),this.o.daysOfWeekDisabled)!==-1},dateIsDisabled:function(b){return this.weekOfDateIsDisabled(b)||a.grep(this.o.datesDisabled,function(a){return e(b,a)}).length>0},dateWithinRange:function(a){return a>=this.o.startDate&&a<=this.o.endDate},keydown:function(a){if(!this.picker.is(":visible"))return void(40!==a.keyCode&&27!==a.keyCode||(this.show(),a.stopPropagation()));var b,c,d=!1,e=this.focusDate||this.viewDate;switch(a.keyCode){case 27:this.focusDate?(this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.fill()):this.hide(),a.preventDefault(),a.stopPropagation();break;case 37:case 38:case 39:case 40:if(!this.o.keyboardNavigation||7===this.o.daysOfWeekDisabled.length)break;b=37===a.keyCode||38===a.keyCode?-1:1,0===this.viewMode?a.ctrlKey?(c=this.moveAvailableDate(e,b,"moveYear"),c&&this._trigger("changeYear",this.viewDate)):a.shiftKey?(c=this.moveAvailableDate(e,b,"moveMonth"),c&&this._trigger("changeMonth",this.viewDate)):37===a.keyCode||39===a.keyCode?c=this.moveAvailableDate(e,b,"moveDay"):this.weekOfDateIsDisabled(e)||(c=this.moveAvailableDate(e,b,"moveWeek")):1===this.viewMode?(38!==a.keyCode&&40!==a.keyCode||(b*=4),c=this.moveAvailableDate(e,b,"moveMonth")):2===this.viewMode&&(38!==a.keyCode&&40!==a.keyCode||(b*=4),c=this.moveAvailableDate(e,b,"moveYear")),c&&(this.focusDate=this.viewDate=c,this.setValue(),this.fill(),a.preventDefault());break;case 13:if(!this.o.forceParse)break;e=this.focusDate||this.dates.get(-1)||this.viewDate,this.o.keyboardNavigation&&(this._toggle_multidate(e),d=!0),this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.setValue(),this.fill(),this.picker.is(":visible")&&(a.preventDefault(),a.stopPropagation(),this.o.autoclose&&this.hide());break;case 9:this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.fill(),this.hide()}d&&(this.dates.length?this._trigger("changeDate"):this._trigger("clearDate"),this.inputField.trigger("change"))},setViewMode:function(a){this.viewMode=a,this.picker.children("div").hide().filter(".datepicker-"+r.viewModes[this.viewMode].clsName).show(),this.updateNavArrows(),this._trigger("changeViewMode",new Date(this.viewDate))}};var l=function(b,c){a.data(b,"datepicker",this),this.element=a(b),this.inputs=a.map(c.inputs,function(a){return a.jquery?a[0]:a}),delete c.inputs,this.keepEmptyValues=c.keepEmptyValues,delete c.keepEmptyValues,n.call(a(this.inputs),c).on("changeDate",a.proxy(this.dateUpdated,this)),this.pickers=a.map(this.inputs,function(b){return a.data(b,"datepicker")}),this.updateDates()};l.prototype={updateDates:function(){this.dates=a.map(this.pickers,function(a){return a.getUTCDate()}),this.updateRanges()},updateRanges:function(){var b=a.map(this.dates,function(a){return a.valueOf()});a.each(this.pickers,function(a,c){c.setRange(b)})},dateUpdated:function(c){if(!this.updating){this.updating=!0;var d=a.data(c.target,"datepicker");if(d!==b){var e=d.getUTCDate(),f=this.keepEmptyValues,g=a.inArray(c.target,this.inputs),h=g-1,i=g+1,j=this.inputs.length;if(g!==-1){if(a.each(this.pickers,function(a,b){b.getUTCDate()||b!==d&&f||b.setUTCDate(e)}),e<this.dates[h])for(;h>=0&&e<this.dates[h];)this.pickers[h--].setUTCDate(e);else if(e>this.dates[i])for(;i<j&&e>this.dates[i];)this.pickers[i++].setUTCDate(e);this.updateDates(),delete this.updating}}}},destroy:function(){a.map(this.pickers,function(a){a.destroy()}),a(this.inputs).off("changeDate",this.dateUpdated),delete this.element.data().datepicker},remove:f("destroy","Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead")};var m=a.fn.datepicker,n=function(c){var d=Array.apply(null,arguments);d.shift();var e;if(this.each(function(){var b=a(this),f=b.data("datepicker"),g="object"==typeof c&&c;if(!f){var j=h(this,"date"),m=a.extend({},o,j,g),n=i(m.language),p=a.extend({},o,n,j,g);b.hasClass("input-daterange")||p.inputs?(a.extend(p,{inputs:p.inputs||b.find("input").toArray()}),f=new l(this,p)):f=new k(this,p),b.data("datepicker",f)}"string"==typeof c&&"function"==typeof f[c]&&(e=f[c].apply(f,d))}),e===b||e instanceof k||e instanceof l)return this;if(this.length>1)throw new Error("Using only allowed for the collection of a single element ("+c+" function)");return e};a.fn.datepicker=n;var o=a.fn.datepicker.defaults={assumeNearbyYear:!1,autoclose:!1,beforeShowDay:a.noop,beforeShowMonth:a.noop,beforeShowYear:a.noop,beforeShowDecade:a.noop,beforeShowCentury:a.noop,calendarWeeks:!1,clearBtn:!1,toggleActive:!1,daysOfWeekDisabled:[],daysOfWeekHighlighted:[],datesDisabled:[],endDate:1/0,forceParse:!0,format:"mm/dd/yyyy",keepEmptyValues:!1,keyboardNavigation:!0,language:"en",minViewMode:0,maxViewMode:4,multidate:!1,multidateSeparator:",",orientation:"auto",rtl:!1,startDate:-(1/0),startView:0,todayBtn:!1,todayHighlight:!1,updateViewDate:!0,weekStart:0,disableTouchKeyboard:!1,enableOnReadonly:!0,showOnFocus:!0,zIndexOffset:10,container:"body",immediateUpdates:!1,title:"",templates:{leftArrow:"&#x00AB;",rightArrow:"&#x00BB;"},showWeekDays:!0},p=a.fn.datepicker.locale_opts=["format","rtl","weekStart"];a.fn.datepicker.Constructor=k;var q=a.fn.datepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",titleFormat:"MM yyyy"}},r={viewModes:[{names:["days","month"],clsName:"days",e:"changeMonth"},{names:["months","year"],clsName:"months",e:"changeYear",navStep:1},{names:["years","decade"],clsName:"years",e:"changeDecade",navStep:10},{names:["decades","century"],clsName:"decades",e:"changeCentury",navStep:100},{names:["centuries","millennium"],clsName:"centuries",e:"changeMillennium",navStep:1e3}],validParts:/dd?|DD?|mm?|MM?|yy(?:yy)?/g,nonpunctuation:/[^ -\/:-@\u5e74\u6708\u65e5\[-`{-~\t\n\r]+/g,parseFormat:function(a){if("function"==typeof a.toValue&&"function"==typeof a.toDisplay)return a;var b=a.replace(this.validParts,"\0").split("\0"),c=a.match(this.validParts);if(!b||!b.length||!c||0===c.length)throw new Error("Invalid date format.");return{separators:b,parts:c}},parseDate:function(c,e,f,g){function h(a,b){return b===!0&&(b=10),a<100&&(a+=2e3,a>(new Date).getFullYear()+b&&(a-=100)),a}function i(){var a=this.slice(0,j[n].length),b=j[n].slice(0,a.length);return a.toLowerCase()===b.toLowerCase()}if(!c)return b;if(c instanceof Date)return c;if("string"==typeof e&&(e=r.parseFormat(e)),e.toValue)return e.toValue(c,e,f);var j,l,m,n,o,p={d:"moveDay",m:"moveMonth",w:"moveWeek",y:"moveYear"},s={yesterday:"-1d",today:"+0d",tomorrow:"+1d"};if(c in s&&(c=s[c]),/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/i.test(c)){for(j=c.match(/([\-+]\d+)([dmwy])/gi),c=new Date,n=0;n<j.length;n++)l=j[n].match(/([\-+]\d+)([dmwy])/i),m=Number(l[1]),o=p[l[2].toLowerCase()],c=k.prototype[o](c,m);return k.prototype._zero_utc_time(c)}j=c&&c.match(this.nonpunctuation)||[];var t,u,v={},w=["yyyy","yy","M","MM","m","mm","d","dd"],x={yyyy:function(a,b){return a.setUTCFullYear(g?h(b,g):b)},m:function(a,b){if(isNaN(a))return a;for(b-=1;b<0;)b+=12;for(b%=12,a.setUTCMonth(b);a.getUTCMonth()!==b;)a.setUTCDate(a.getUTCDate()-1);return a},d:function(a,b){return a.setUTCDate(b)}};x.yy=x.yyyy,x.M=x.MM=x.mm=x.m,x.dd=x.d,c=d();var y=e.parts.slice();if(j.length!==y.length&&(y=a(y).filter(function(b,c){return a.inArray(c,w)!==-1}).toArray()),j.length===y.length){var z;for(n=0,z=y.length;n<z;n++){if(t=parseInt(j[n],10),l=y[n],isNaN(t))switch(l){case"MM":u=a(q[f].months).filter(i),t=a.inArray(u[0],q[f].months)+1;break;case"M":u=a(q[f].monthsShort).filter(i),t=a.inArray(u[0],q[f].monthsShort)+1}v[l]=t}var A,B;for(n=0;n<w.length;n++)B=w[n],B in v&&!isNaN(v[B])&&(A=new Date(c),x[B](A,v[B]),isNaN(A)||(c=A))}return c},formatDate:function(b,c,d){if(!b)return"";if("string"==typeof c&&(c=r.parseFormat(c)),c.toDisplay)return c.toDisplay(b,c,d);var e={d:b.getUTCDate(),D:q[d].daysShort[b.getUTCDay()],DD:q[d].days[b.getUTCDay()],m:b.getUTCMonth()+1,M:q[d].monthsShort[b.getUTCMonth()],MM:q[d].months[b.getUTCMonth()],yy:b.getUTCFullYear().toString().substring(2),yyyy:b.getUTCFullYear()};e.dd=(e.d<10?"0":"")+e.d,e.mm=(e.m<10?"0":"")+e.m,b=[];for(var f=a.extend([],c.separators),g=0,h=c.parts.length;g<=h;g++)f.length&&b.push(f.shift()),b.push(e[c.parts[g]]);return b.join("")},headTemplate:'<thead><tr><th colspan="7" class="datepicker-title"></th></tr><tr><th class="prev">'+o.templates.leftArrow+'</th><th colspan="5" class="datepicker-switch"></th><th class="next">'+o.templates.rightArrow+"</th></tr></thead>",
+contTemplate:'<tbody><tr><td colspan="7"></td></tr></tbody>',footTemplate:'<tfoot><tr><th colspan="7" class="today"></th></tr><tr><th colspan="7" class="clear"></th></tr></tfoot>'};r.template='<div class="datepicker"><div class="datepicker-days"><table class="table-condensed">'+r.headTemplate+"<tbody></tbody>"+r.footTemplate+'</table></div><div class="datepicker-months"><table class="table-condensed">'+r.headTemplate+r.contTemplate+r.footTemplate+'</table></div><div class="datepicker-years"><table class="table-condensed">'+r.headTemplate+r.contTemplate+r.footTemplate+'</table></div><div class="datepicker-decades"><table class="table-condensed">'+r.headTemplate+r.contTemplate+r.footTemplate+'</table></div><div class="datepicker-centuries"><table class="table-condensed">'+r.headTemplate+r.contTemplate+r.footTemplate+"</table></div></div>",a.fn.datepicker.DPGlobal=r,a.fn.datepicker.noConflict=function(){return a.fn.datepicker=m,this},a.fn.datepicker.version="1.7.1",a.fn.datepicker.deprecated=function(a){var b=window.console;b&&b.warn&&b.warn("DEPRECATED: "+a)},a(document).on("focus.datepicker.data-api click.datepicker.data-api",'[data-provide="datepicker"]',function(b){var c=a(this);c.data("datepicker")||(b.preventDefault(),n.call(c,"show"))}),a(function(){n.call(a('[data-provide="datepicker-inline"]'))})});
