Ejemplo n.º 1
0
    def exec(self) -> dict:
        for node in self.graph.nodes:
            if self.field in node.data:
                start_year = EthiopianDateConverter.to_gregorian(
                    int(node.data), 1, 1)
                end_year = EthiopianDateConverter.to_gregorian(
                    int(node.data), 12, 31)
                node.data[self.field] = f"{start_year}/{end_year}"
            return {"graph": self.graph}

        return {"data": self.graph}
Ejemplo n.º 2
0
def get_gregorian_to_ethiopian(date_input):
    '''
    Takes a gregorian date string or datetime and converts it to
    the equivalent ethiopian date

    :param date_input: A datetime or date string
    :returns: An ethiopian date string or ''
    '''
    if not date_input:
        return ''

    try:
        if isinstance(date_input, date):
            date_input = date_input.strftime('%Y-%m-%d')
        year, month, day = split_date_string(date_input)
    except ValueError:
        return ''

    try:
        ethiopian_year, ethiopian_month, ethiopian_day = EthiopianDateConverter.to_ethiopian(
            year, month, day)
        return '{}-{:02d}-{:02d}'.format(ethiopian_year, ethiopian_month,
                                         ethiopian_day)
    except Exception:
        return ''
Ejemplo n.º 3
0
def get_ethiopian_to_gregorian(date_string):
    '''
    Takes a string ethiopian date and converts it to
    the equivalent gregorian date

    :param date_string: A date string that is in the format YYYY-MM-DD
    :returns: A gregorian datetime or ''
    '''
    if not date_string:
        return ''

    try:
        year, month, day = split_date_string(date_string)
    except ValueError:
        return ''

    try:
        return EthiopianDateConverter.to_gregorian(year, month, day)
    except Exception:
        return ''
Ejemplo n.º 4
0
def get_ethiopian_to_gregorian(date_string):
    '''
    Takes a string ethiopian date and converts it to
    the equivalent gregorian date

    :param date_string: A date string that is in the format YYYY-MM-DD
    :returns: A gregorian datetime or ''
    '''
    if not date_string:
        return ''

    try:
        year, month, day = split_date_string(date_string)
    except ValueError:
        return ''

    try:
        return EthiopianDateConverter.to_gregorian(year, month, day)
    except Exception:
        return ''
Ejemplo n.º 5
0
def get_gregorian_to_ethiopian(date_input):
    '''
    Takes a gregorian date string or datetime and converts it to
    the equivalent ethiopian date

    :param date_input: A datetime or date string
    :returns: An ethiopian date string or ''
    '''
    if not date_input:
        return ''

    try:
        if isinstance(date_input, date):
            date_input = date_input.strftime('%Y-%m-%d')
        year, month, day = split_date_string(date_input)
    except ValueError:
        return ''

    try:
        ethiopian_year, ethiopian_month, ethiopian_day = EthiopianDateConverter.to_ethiopian(year, month, day)
        return '{}-{:02d}-{:02d}'.format(ethiopian_year, ethiopian_month, ethiopian_day)
    except Exception:
        return ''
Ejemplo n.º 6
0
def getEthiopianCalendarDateNameOperator( n ):
    date = list( ethiopian_date.to_ethiopian( n.year, n.month, n.day ) )

    return ethiopianDays[ date[ 2 ] - 1 ] + ' ' + ethiopianMonths[ date[ 1 ] - 1 ] + \
                          ' ' + str( date[ 0 ] )
Ejemplo n.º 7
0
def convertEthiopianDateOperator( year, month, day ):
    ethDate = ethiopian_date.to_gregorian( int( year ), int( month ), int( day ) )
    return RPNDateTime( ethDate.year, ethDate.month, ethDate.day )
Ejemplo n.º 8
0
def getEthiopianCalendarDateOperator( n ):
    return list( ethiopian_date.to_ethiopian( n.year, n.month, n.day ) )
Ejemplo n.º 9
0
    def __init__(self, graph1: Graph, field: str):
        self.graph = graph1
        self.field = field

        self.converter = EthiopianDateConverter()