def format_date(datetext): """Display date in human readable form from available metadata.""" datestruct = create_datestruct(datetext) if datestruct: dummy_time = (0, 0, 44, 2, 320, 0) if len(datestruct) == 3: datestruct = datestruct + dummy_time date = convert_datestruct_to_dategui(datestruct, output_format="MMM d, Y") return date elif len(datestruct) == 2: datestruct = datestruct + (1, ) + dummy_time date = convert_datestruct_to_dategui(datestruct, output_format="MMM Y") return date elif len(datestruct) == 1: # XXX(jacquerie): returns int instead of string. return datestruct[0]
def format_date(datetext): """Display date in human readable form from available metadata.""" datestruct = create_datestruct(datetext) if datestruct: dummy_time = (0, 0, 44, 2, 320, 0) if len(datestruct) == 3: datestruct = datestruct + dummy_time date = convert_datestruct_to_dategui( datestruct, output_format="MMM d, Y" ) return date elif len(datestruct) == 2: datestruct = datestruct + (1,) + dummy_time date = convert_datestruct_to_dategui( datestruct, output_format="MMM Y" ) return date elif len(datestruct) == 1: # XXX(jacquerie): returns int instead of string. return datestruct[0]
def format_date(datetext): """Display date in human readable form from available metadata.""" from inspirehep.utils.date import create_datestruct from invenio_utils.date import convert_datestruct_to_dategui datestruct = create_datestruct(datetext) if datestruct: dummy_time = (0, 0, 44, 2, 320, 0) if len(datestruct) == 3: datestruct = datestruct + dummy_time date = convert_datestruct_to_dategui( datestruct, output_format="MMM d, Y" ) return date elif len(datestruct) == 2: datestruct = datestruct + (1,) + dummy_time date = convert_datestruct_to_dategui( datestruct, output_format="MMM Y" ) return date elif len(datestruct) == 1: return datestruct[0]
def test_create_datestruct(): """TODO.""" assert create_datestruct('2002-01-05') == (2002, 1, 5) assert create_datestruct('1877-02') == (1877, 2) assert create_datestruct('1900') == (1900, )