#
# This module contains two functions for converting between natural
# numbers expressing times in seconds since midnight January 1, 1970 and
# strings of the form 'Fri Mar 18 1:58:31 2005 +0100'. The time zone
# abbreviation is ignored, but time zones can be specified as +0500,
# etc.. Days of the week are output correctly but ignored in the input.
# Fields can be written in any order but must be separated by spaces.
# Commas are optional.
#
# Copyright (C) 2007-2009 Dennis Furey
#
# one_time                                     (217)
# string_to_time                            (128327)
# time_to_string                            (240056)
#
# compressed with granularity 89
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
{kwwzkowzkHgxz{fnfkHgxz{fffgFfxnkowzggvfkfnjkHgxz{fcebfvUfjdfnfkHgxz{fbVUFeebg^
zfgvhggoF{G{ve``Fue`fZbVkebfvbgFvxnkGoZfL^e``FbVUF^VUfefVgjVhffwEVivdf`DfUE>jVU
FujVfVEffzgoFnhsffdf`DfUE>ebbNjWbgvUfjtajnkwFff^fL^e``FbVUVbVUfkEgoGhz{dgFff^fL
^e``FebbNfnb\vgggxzsgDgFff^fL^fUE>fk`{TGgvxvkwiz>nFnffd^e>VfbTnHfveZggrkInwKVdG
DkFff^fgbOeFodezgrhbgfhgoKkgdGFFnfhnebDbfKo\Sfjbgbgnvvjjqns^f\gDgFDfUIxfyBB[fkU
fbVgjbefykJqgivj^>nFf`D{F_wFHAvfnUgbNgrVWbfnVvbTNjwZ^ftGDdkHFoPf_cvffUFU^fnUeeb
ffV{ICFxjgZfvf>gKjGKO^<=JfkbFUFfu``bNgueXniFgfxoiv^ffn_SIfKGNkzfbUFLffU^E>fU`yV
JgFkFjhjwZffF^gAaFqM]f]Zh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