Exemplo n.º 1
0
def convert_isv_date(date_string, language_code='en_US'):
    try:
        date = ParseDateTimeUTC(date_string)
    except ValueError:
        date = ParseDateTimeUTC(date_string[0:4])
    if len(language_code) == 5:
        language_code = language_code[0:2] + '_' + language_code[3:5]
    #print language_code, locale.normalize(language_code)
    locale.setlocale(locale.LC_ALL, (language_code, 'utf-8'))
    if len(date_string) >= 9:
        return date.strftime("%e %B %Y").strip()
    if len(date_string) >= 6:
        return date.strftime("%B %Y")
    return date.strftime("%Y")
Exemplo n.º 2
0
def convert_isv_date(date_string, language_code = 'en_US'):
    try:
        date = ParseDateTimeUTC(date_string)
    except ValueError:
        date = ParseDateTimeUTC(date_string[0:4])
    if len(language_code) == 5:
        language_code = language_code[0:2] + '_' + language_code[3:5]
    #print language_code, locale.normalize(language_code)
    locale.setlocale(locale.LC_ALL, (language_code,'utf-8'))
    if len(date_string) >= 9:
        return date.strftime("%e %B %Y").strip() 
    if len(date_string) >= 6:
        return date.strftime("%B %Y") 
    return date.strftime("%Y")
Exemplo n.º 3
0
def get_printings(original_story, first_publication_date):
    printings = Story.objects.filter(story_version__base_story =\
                original_story).filter(issue__publication_date__gt = "")\
                .order_by('issue__publication_date')
    if len(first_publication_date) <= 4 or 'Q' in first_publication_date:
        first_printings = printings.filter(issue__publication_date__icontains\
            = first_publication_date[0:4])
    else:
        end_date = ParseDateTimeUTC(first_publication_date[0:7])
        end_date += DateTimeDelta(120)
        end_date = end_date.strftime("%Y-%m")
        first_printings = printings.filter(issue__publication_date__gte \
            = first_publication_date[0:7]).filter(issue__publication_date__lte \
            = end_date)
        if not first_printings:
            first_printings = \
                printings.filter(issue__publication_date__icontains \
                = first_publication_date[0:4])
    return printings, first_printings
Exemplo n.º 4
0
def get_printings(original_story, first_publication_date):
    printings = Story.objects.filter(story_version__base_story =\
                original_story).filter(issue__publication_date__gt = "")\
                .order_by('issue__publication_date')
    if len(first_publication_date) <= 4 or 'Q' in first_publication_date:
        first_printings = printings.filter(issue__publication_date__icontains\
            = first_publication_date[0:4])
    else:
        end_date = ParseDateTimeUTC(first_publication_date[0:7])
        end_date += DateTimeDelta(120)
        end_date = end_date.strftime("%Y-%m")
        first_printings = printings.filter(issue__publication_date__gte \
            = first_publication_date[0:7]).filter(issue__publication_date__lte \
            = end_date)
        if not first_printings:
            first_printings = \
                printings.filter(issue__publication_date__icontains \
                = first_publication_date[0:4])
    return printings,first_printings