Back to index

moin  1.9.0~rc2
marshall.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright (C) 2007 Lemur Consulting Ltd
00004 #
00005 # This program is free software; you can redistribute it and/or modify
00006 # it under the terms of the GNU General Public License as published by
00007 # the Free Software Foundation; either version 2 of the License, or
00008 # (at your option) any later version.
00009 #
00010 # This program is distributed in the hope that it will be useful,
00011 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 # GNU General Public License for more details.
00014 # 
00015 # You should have received a copy of the GNU General Public License along
00016 # with this program; if not, write to the Free Software Foundation, Inc.,
00017 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 r"""marshall.py: Marshal values into strings
00019 
00020 """
00021 __docformat__ = "restructuredtext en"
00022 
00023 import math
00024 import xapian
00025 from replaylog import log as _log
00026 
00027 def float_to_string(value):
00028     """Marshall a floating point number to a string which sorts in the
00029     appropriate manner.
00030 
00031     """
00032     return _log(xapian.sortable_serialise, value)
00033 
00034 def date_to_string(date):
00035     """Marshall a date to a string which sorts in the appropriate manner.
00036 
00037     """
00038     return '%04d%02d%02d' % (date.year, date.month, date.day)