mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-05 11:45:51 +00:00
* Retrieve and process summary or full ledgers. * Search using arbitrary criteria (any Python function). * Search using arbitrary formats (any Python function). * Caches ledgers as .gz files to avoid repeated server requests. * Handles ledger numbers, ranges, and special names like validated or closed.
22 lines
590 B
Python
22 lines
590 B
Python
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
import datetime
|
|
|
|
# Format for human-readable dates in rippled
|
|
_DATE_FORMAT = '%Y-%b-%d'
|
|
_TIME_FORMAT = '%H:%M:%S'
|
|
_DATETIME_FORMAT = '%s %s' % (_DATE_FORMAT, _TIME_FORMAT)
|
|
|
|
_FORMATS = _DATE_FORMAT, _TIME_FORMAT, _DATETIME_FORMAT
|
|
|
|
def parse_datetime(desc):
|
|
for fmt in _FORMATS:
|
|
try:
|
|
return datetime.date.strptime(desc, fmt)
|
|
except:
|
|
pass
|
|
raise ValueError("Can't understand date '%s'." % date)
|
|
|
|
def format_datetime(dt):
|
|
return dt.strftime(_DATETIME_FORMAT)
|