def test_minutes_past_hour(self): # "quarter past ten" dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, lang="pt-pt", use_24hour=True), "uma e quinze") self.assertEqual(nice_time(dt, lang="pt-pt"), "uma e um quarto") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt, lang="pt-pt"), "duas menos vinte e cinco") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt, lang="pt-pt"), "duas menos um quarto") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt, lang="pt-pt"), "cinco menos dez") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt, lang="pt-pt"), "seis menos cinco") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, lang="pt-pt", use_ampm=True), "cinco e meia da madrugada") dt = datetime.datetime(2017, 1, 31, 23, 15, 9) self.assertEqual( nice_time(dt, lang="pt-pt", use_24hour=True, use_ampm=True), "vinte e três e quinze") self.assertEqual( nice_time(dt, lang="pt-pt", use_24hour=False, use_ampm=True), "onze e um quarto da noite")
def test_minutes_to_hour(self): # "twenty minutes to midnight" dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt, lang="pt-pt"), "oito menos vinte") self.assertEqual(nice_time(dt, lang="pt-pt", use_ampm=True), "oito menos vinte da tarde") self.assertEqual(nice_time(dt, lang="pt-pt", speech=False), "7:40") self.assertEqual( nice_time(dt, lang="pt-pt", speech=False, use_ampm=True), "7:40 PM") self.assertEqual( nice_time(dt, lang="pt-pt", speech=False, use_24hour=True), "19:40") self.assertEqual( nice_time(dt, lang="pt-pt", speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual( nice_time(dt, lang="pt-pt", use_24hour=True, use_ampm=True), "dezanove e quarenta") self.assertEqual( nice_time(dt, lang="pt-pt", use_24hour=True, use_ampm=False), "dezanove e quarenta")
def test_midnight(self): dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="pt"), "meia noite e dois") self.assertEqual(nice_time(dt, lang="pt", use_ampm=True), "meia noite e dois") self.assertEqual(nice_time(dt, lang="pt", use_24hour=True), "zero e dois") self.assertEqual(nice_time(dt, lang="pt", speech=False), "12:02") self.assertEqual(nice_time(dt, lang="pt", speech=False, use_ampm=True), "12:02 AM") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=True), "zero e dois") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=False), "zero e dois")
def test_midday(self): dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt, lang="pt-pt"), "meio dia e um quarto") self.assertEqual(nice_time(dt, lang="pt-pt", use_ampm=True), "meio dia e um quarto") self.assertEqual(nice_time(dt, lang="pt-pt", speech=False), "12:15") self.assertEqual( nice_time(dt, lang="pt-pt", speech=False, use_ampm=True), "12:15 PM") self.assertEqual( nice_time(dt, lang="pt-pt", speech=False, use_24hour=True), "12:15") self.assertEqual( nice_time(dt, lang="pt-pt", speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual( nice_time(dt, lang="pt-pt", use_24hour=True, use_ampm=True), "doze e quinze") self.assertEqual( nice_time(dt, lang="pt-pt", use_24hour=True, use_ampm=False), "doze e quinze")
def test_convert_times_da(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) self.assertEqual(nice_time(dt, lang="da-dk"), "et toogtyve") self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "et toogtyve om eftermiddagen") self.assertEqual(nice_time(dt, lang="da-dk", speech=False), "01:22") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_ampm=True), "01:22 PM") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=True), "tretten toogtyve") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=False), "tretten toogtyve") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="da-dk"), "et") self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "et om eftermiddagen") self.assertEqual(nice_time(dt, lang="da-dk", speech=False), "01:00") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_ampm=True), "01:00 PM") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=True), "tretten") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=False), "tretten") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="da-dk"), "et nul to") self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "et nul to om eftermiddagen") self.assertEqual(nice_time(dt, lang="da-dk", speech=False), "01:02") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_ampm=True), "01:02 PM") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=True), "tretten nul to") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=False), "tretten nul to") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="da-dk"), "tolv nul to") self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "tolv nul to om natten") self.assertEqual(nice_time(dt, lang="da-dk", speech=False), "12:02") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_ampm=True), "12:02 AM") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=True), "nul nul to") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=False), "nul nul to") dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt, lang="da-dk"), "tolv femten") self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "tolv femten om eftermiddagen") self.assertEqual(nice_time(dt, lang="da-dk", speech=False), "12:15") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_ampm=True), "12:15 PM") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True), "12:15") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=True), "tolv femten") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=False), "tolv femten") dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt, lang="da-dk"), "syv fyrre") self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "syv fyrre om aftenen") self.assertEqual(nice_time(dt, lang="da-dk", speech=False), "07:40") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_ampm=True), "07:40 PM") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True), "19:40") self.assertEqual( nice_time(dt, lang="da-dk", speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=True), "nitten fyrre") self.assertEqual( nice_time(dt, lang="da-dk", use_24hour=True, use_ampm=False), "nitten fyrre") dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, lang="da-dk", use_24hour=True), "et femten") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt, lang="da-dk"), "et femogtredive") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt, lang="da-dk"), "et femogfyrre") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt, lang="da-dk"), "fire halvtres") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt, lang="da-dk"), "fem femoghalvtres") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, lang="da-dk", use_ampm=True), "fem tredive om morgenen")
def test_convert_times_de(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) self.assertEqual(nice_time(dt), "ein Uhr zweiundzwanzig") self.assertEqual(nice_time(dt, use_ampm=True), "ein Uhr zweiundzwanzig nachmittags") self.assertEqual(nice_time(dt, speech=False), "1:22") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:22 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "dreizehn Uhr zweiundzwanzig") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "dreizehn Uhr zweiundzwanzig") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt), "ein Uhr") self.assertEqual(nice_time(dt, use_ampm=True), "ein Uhr nachmittags") self.assertEqual(nice_time(dt, speech=False), "1:00") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:00 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "dreizehn Uhr") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "dreizehn Uhr") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt), "ein Uhr zwei") self.assertEqual(nice_time(dt, use_ampm=True), "ein Uhr zwei nachmittags") self.assertEqual(nice_time(dt, speech=False), "1:02") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:02 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "dreizehn Uhr zwei") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "dreizehn Uhr zwei") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt), u"zwölf Uhr zwei") self.assertEqual(nice_time(dt, use_ampm=True), u"zwölf Uhr zwei nachts") self.assertEqual(nice_time(dt, speech=False), "12:02") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "12:02 AM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "null Uhr zwei") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "null Uhr zwei") dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt), u"zwölf Uhr fünfzehn") self.assertEqual(nice_time(dt, use_ampm=True), u"zwölf Uhr fünfzehn nachmittags") self.assertEqual(nice_time(dt, speech=False), "12:15") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "12:15 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "12:15") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), u"zwölf Uhr fünfzehn") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), u"zwölf Uhr fünfzehn") dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt), "sieben Uhr vierzig") self.assertEqual(nice_time(dt, use_ampm=True), "sieben Uhr vierzig abends") self.assertEqual(nice_time(dt, speech=False), "7:40") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "7:40 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "19:40") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "neunzehn Uhr vierzig") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "neunzehn Uhr vierzig") dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, use_24hour=True), u"ein Uhr fünfzehn") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt), u"ein Uhr fünfunddreißig") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt), u"ein Uhr fünfundvierzig") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt), u"vier Uhr fünfzig") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt), u"fünf Uhr fünfundfünfzig") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, use_ampm=True), u"fünf Uhr dreißig morgens")
def test_convert_times(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) # Verify defaults haven't changed self.assertEqual(nice_time(dt, lang="es-es"), nice_time(dt, "es-es", True, False, False)) self.assertEqual(nice_time(dt, lang="es"), "la una y veintidós") self.assertEqual(nice_time(dt, lang="es", use_ampm=True), "la una y veintidós de la tarde") self.assertEqual(nice_time(dt, lang="es", speech=False), "1:22") self.assertEqual(nice_time(dt, lang="es", speech=False, use_ampm=True), "1:22 PM") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=True), "las trece veintidós") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=False), "las trece veintidós") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="es"), "la una en punto") self.assertEqual(nice_time(dt, lang="es", use_ampm=True), "la una de la tarde") self.assertEqual(nice_time(dt, lang="es", speech=False), "1:00") self.assertEqual(nice_time(dt, lang="es", speech=False, use_ampm=True), "1:00 PM") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=True), "las trece cero cero") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="es", use_24hour=True), "las trece cero dos") self.assertEqual(nice_time(dt, lang="es", use_ampm=True), "la una y dos de la tarde") self.assertEqual(nice_time(dt, lang="es", speech=False), "1:02") self.assertEqual(nice_time(dt, lang="es", speech=False, use_ampm=True), "1:02 PM") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=True), "las trece cero dos") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=False), "las trece cero dos") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="es"), "las doce y dos") self.assertEqual(nice_time(dt, lang="es", use_ampm=True), "las doce y dos de la madrugada") self.assertEqual(nice_time(dt, lang="es", use_24hour=True), "las cero cero dos") self.assertEqual(nice_time(dt, lang="es", speech=False), "12:02") self.assertEqual(nice_time(dt, lang="es", speech=False, use_ampm=True), "12:02 AM") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, lang="es", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=True), "las cero cero dos") self.assertEqual( nice_time(dt, lang="es", use_24hour=True, use_ampm=False), "las cero cero dos") dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt, lang="es-es"), "las doce y cuarto") self.assertEqual(nice_time(dt, lang="es-es", use_ampm=True), "las doce y cuarto de la mañana") self.assertEqual(nice_time(dt, lang="es-es", speech=False), "12:15") self.assertEqual( nice_time(dt, lang="es-es", speech=False, use_ampm=True), "12:15 PM") self.assertEqual( nice_time(dt, lang="es-es", speech=False, use_24hour=True), "12:15") self.assertEqual( nice_time(dt, lang="es-es", speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual( nice_time(dt, lang="es-es", use_24hour=True, use_ampm=True), "las doce quince") self.assertEqual( nice_time(dt, lang="es-es", use_24hour=True, use_ampm=False), "las doce quince") dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt, lang="es-es"), "las ocho menos veinte") self.assertEqual(nice_time(dt, lang="es-es", use_ampm=True), "las ocho menos veinte de la tarde") self.assertEqual(nice_time(dt, lang="es-es", speech=False), "7:40") self.assertEqual( nice_time(dt, lang="es-es", speech=False, use_ampm=True), "7:40 PM") self.assertEqual( nice_time(dt, lang="es-es", speech=False, use_24hour=True), "19:40") self.assertEqual( nice_time(dt, lang="es-es", speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual( nice_time(dt, lang="es-es", use_24hour=True, use_ampm=True), "las diecinueve cuarenta") self.assertEqual( nice_time(dt, lang="es-es", use_24hour=True, use_ampm=False), "las diecinueve cuarenta") dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, lang="es-es", use_24hour=True), "la una quince") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt, lang="es-es"), "las dos menos veinticinco") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt, lang="es-es"), "las dos menos cuarto") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt, lang="es-es"), "las cinco menos diez") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt, lang="es-es"), "las seis menos cinco") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, lang="es-es", use_ampm=True), "las cinco y media de la madrugada") dt = datetime.datetime(2017, 1, 31, 23, 15, 9) self.assertEqual( nice_time(dt, lang="es-es", use_24hour=True, use_ampm=True), "las veintitrés quince") self.assertEqual( nice_time(dt, lang="es-es", use_24hour=False, use_ampm=True), "las once y cuarto de la noche")
"two hundred and ninety nine million, seven hundred and ninety " \ "two thousand, four hundred and fifty eight" assert pronounce_number(100034000000299792458, short_scale=False) == \ "one hundred trillion, thirty four thousand billion, " \ "two hundred and ninety nine million, seven hundred and ninety " \ "two thousand, four hundred and fifty eight" # pronounce datetime objects import datetime dt = datetime.datetime(2017, 1, 31, 13, 22, 3) assert nice_date(dt) == "tuesday, january thirty-first, twenty seventeen" assert nice_time(dt) == "one twenty two" assert nice_time(dt, use_ampm=True) == "one twenty two p.m." assert nice_time(dt, speech=False) == "1:22" assert nice_time(dt, speech=False, use_ampm=True) == "1:22 PM" assert nice_time(dt, speech=False, use_24hour=True) == "13:22" assert nice_time(dt, speech=False, use_24hour=True, use_ampm=True) == "13:22" assert nice_time(dt, use_24hour=True, use_ampm=True) == "thirteen twenty two" assert nice_time(dt, use_24hour=True, use_ampm=False) == "thirteen twenty two" assert nice_date_time( dt) == "tuesday, january thirty-first, twenty seventeen at one twenty two" # pronounce durations assert nice_duration(1) == "one second" assert nice_duration(3) == "three seconds" assert nice_duration(1, speech=False) == "0:01"
def test_convert_times(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) # Verify defaults haven't changed self.assertEqual(nice_time(dt, lang="it-it"), nice_time(dt, "it-it", True, False, False)) self.assertEqual(nice_time(dt, lang="it"), "una e ventidue") self.assertEqual(nice_time(dt, lang="it", use_ampm=True), "una e ventidue del pomeriggio") self.assertEqual(nice_time(dt, lang="it", speech=False), "1:22") self.assertEqual(nice_time(dt, lang="it", speech=False, use_ampm=True), "1:22 PM") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True), "13:22") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=True), "tredici e ventidue") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=False), "tredici e ventidue") # Verifica fasce orarie use_ampm = True d_time = datetime.datetime(2017, 1, 31, 8, 22, 3) self.assertEqual(nice_time(d_time, lang="it", use_ampm=True), "otto e ventidue della mattina") d_time = datetime.datetime(2017, 1, 31, 20, 22, 3) self.assertEqual(nice_time(d_time, lang="it", use_ampm=True), "otto e ventidue della sera") d_time = datetime.datetime(2017, 1, 31, 23, 22, 3) self.assertEqual(nice_time(d_time, lang="it", use_ampm=True), "undici e ventidue della notte") d_time = datetime.datetime(2017, 1, 31, 00, 00, 3) self.assertEqual(nice_time(d_time, lang="it", use_ampm=True), "mezzanotte") d_time = datetime.datetime(2017, 1, 31, 12, 00, 3) self.assertEqual(nice_time(d_time, lang="it", use_ampm=True), "mezzogiorno") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="it"), "una in punto") self.assertEqual(nice_time(dt, lang="it", use_ampm=True), "una del pomeriggio") self.assertEqual(nice_time(dt, lang="it", speech=False), "1:00") self.assertEqual(nice_time(dt, lang="it", speech=False, use_ampm=True), "1:00 PM") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True), "13:00") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=True), "tredici e zerozero") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=False), "tredici e zerozero") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="it", use_24hour=True), "tredici e zero due") self.assertEqual(nice_time(dt, lang="it", use_ampm=True), "una e zero due del pomeriggio") self.assertEqual(nice_time(dt, lang="it", speech=False), "1:02") self.assertEqual(nice_time(dt, lang="it", speech=False, use_ampm=True), "1:02 PM") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True), "13:02") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=True), "tredici e zero due") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=False), "tredici e zero due") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="it"), "mezzanotte e zero due") self.assertEqual(nice_time(dt, lang="it", use_ampm=True), "mezzanotte e zero due") self.assertEqual(nice_time(dt, lang="it", speech=False), "12:02") self.assertEqual(nice_time(dt, lang="it", speech=False, use_ampm=True), "12:02 AM") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True), "00:02") self.assertEqual(nice_time(dt, lang="it", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=True), "zerozero e zero due") self.assertEqual(nice_time(dt, lang="it", use_24hour=True, use_ampm=False), "zerozero e zero due") # casi particolari d_time = datetime.datetime(2017, 1, 31, 1, 2, 3) self.assertEqual(nice_time(d_time, lang="it", use_24hour=True, use_ampm=True), "una e zero due") d_time = datetime.datetime(2017, 1, 31, 2, 2, 3) self.assertEqual(nice_time(d_time, lang="it", use_24hour=True, use_ampm=False), "zero due e zero due") d_time = datetime.datetime(2017, 1, 31, 10, 15, 0) self.assertEqual(nice_time(d_time, lang="it", use_24hour=False, use_ampm=False), "dieci e un quarto") d_time = datetime.datetime(2017, 1, 31, 22, 45, 0) self.assertEqual(nice_time(d_time, lang="it", use_24hour=False, use_ampm=False), "dieci e tre quarti")
def test_convert_times(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) # Verify defaults haven't changed self.assertEqual(nice_time(dt), nice_time(dt, "en-us", True, False, False)) self.assertEqual(nice_time(dt), "one twenty two") self.assertEqual(nice_time(dt, use_ampm=True), "one twenty two p.m.") self.assertEqual(nice_time(dt, speech=False), "1:22") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:22 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "thirteen twenty two") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "thirteen twenty two") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt), "one o'clock") self.assertEqual(nice_time(dt, use_ampm=True), "one p.m.") self.assertEqual(nice_time(dt, speech=False), "1:00") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:00 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "thirteen hundred") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "thirteen hundred") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt), "one oh two") self.assertEqual(nice_time(dt, use_ampm=True), "one oh two p.m.") self.assertEqual(nice_time(dt, speech=False), "1:02") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:02 PM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "thirteen zero two") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "thirteen zero two") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt), "twelve oh two") self.assertEqual(nice_time(dt, use_ampm=True), "twelve oh two a.m.") self.assertEqual(nice_time(dt, speech=False), "12:02") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "12:02 AM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "zero zero zero two") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "zero zero zero two") dt = datetime.datetime(2018, 2, 8, 1, 2, 33) self.assertEqual(nice_time(dt), "one oh two") self.assertEqual(nice_time(dt, use_ampm=True), "one oh two a.m.") self.assertEqual(nice_time(dt, speech=False), "1:02") self.assertEqual(nice_time(dt, speech=False, use_ampm=True), "1:02 AM") self.assertEqual(nice_time(dt, speech=False, use_24hour=True), "01:02") self.assertEqual( nice_time(dt, speech=False, use_24hour=True, use_ampm=True), "01:02") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=True), "zero one zero two") self.assertEqual(nice_time(dt, use_24hour=True, use_ampm=False), "zero one zero two")
def test_convert_times_fr(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) self.assertEqual(nice_time(dt, lang="fr-fr"), "une heure vingt-deux") self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "une heure vingt-deux de l'après-midi") self.assertEqual(nice_time(dt, lang="fr-fr", speech=False), "1:22") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_ampm=True), "1:22 PM") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=True), "treize heures vingt-deux") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=False), "treize heures vingt-deux") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="fr-fr"), "une heure") self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "une heure de l'après-midi") self.assertEqual(nice_time(dt, lang="fr-fr", speech=False), "1:00") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_ampm=True), "1:00 PM") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=True), "treize heures") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=False), "treize heures") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="fr-fr"), "une heure deux") self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "une heure deux de l'après-midi") self.assertEqual(nice_time(dt, lang="fr-fr", speech=False), "1:02") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_ampm=True), "1:02 PM") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=True), "treize heures deux") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=False), "treize heures deux") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="fr-fr"), "minuit deux") self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "minuit deux") self.assertEqual(nice_time(dt, lang="fr-fr", speech=False), "12:02") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_ampm=True), "12:02 AM") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=True), "minuit deux") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=False), "minuit deux") dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt, lang="fr-fr"), "midi et quart") self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "midi et quart") self.assertEqual(nice_time(dt, lang="fr-fr", speech=False), "12:15") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_ampm=True), "12:15 PM") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True), "12:15") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=True), "midi quinze") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=False), "midi quinze") dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt, lang="fr-fr"), "huit heures moins vingt") self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "huit heures moins vingt du soir") self.assertEqual(nice_time(dt, lang="fr-fr", speech=False), "7:40") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_ampm=True), "7:40 PM") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True), "19:40") self.assertEqual( nice_time(dt, lang="fr-fr", speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=True), "dix-neuf heures quarante") self.assertEqual( nice_time(dt, lang="fr-fr", use_24hour=True, use_ampm=False), "dix-neuf heures quarante") dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, lang="fr-fr", use_24hour=True), "une heure quinze") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt, lang="fr-fr"), "deux heures moins vingt-cinq") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt, lang="fr-fr"), "deux heures moins le quart") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt, lang="fr-fr"), "cinq heures moins dix") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt, lang="fr-fr"), "six heures moins cinq") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, lang="fr-fr", use_ampm=True), "cinq heures et demi du matin")
def test_convert_times_nl(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) self.assertEqual(nice_time(dt, lang="nl-nl"), u"tweeentwintig over één") self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), u"tweeentwintig over één 's middags") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False), "1:22") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_ampm=True), "1:22 PM") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True), "13:22") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=True), "dertien uur tweeentwintig") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=False), "dertien uur tweeentwintig") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="nl-nl"), u"één uur") self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), u"één uur 's middags") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False), "1:00") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_ampm=True), "1:00 PM") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True), "13:00") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=True), "dertien uur") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=False), "dertien uur") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="nl-nl"), u"twee over één") self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), u"twee over één 's middags") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False), "1:02") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_ampm=True), "1:02 PM") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True), "13:02") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=True), "dertien uur twee") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=False), "dertien uur twee") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="nl-nl"), "twee over twaalf") self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), "twee over twaalf 's nachts") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False), "12:02") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_ampm=True), "12:02 AM") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True), "00:02") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=True), "nul uur twee") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=False), "nul uur twee") dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt, lang="nl-nl"), "kwart over twaalf") self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), "kwart over twaalf 's middags") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False), "12:15") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_ampm=True), "12:15 PM") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True), "12:15") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=True), "twaalf uur vijftien") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=False), "twaalf uur vijftien") dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt, lang="nl-nl"), "twintig voor acht") self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), "twintig voor acht 's avonds") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False), "7:40") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_ampm=True), "7:40 PM") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True), "19:40") self.assertEqual(nice_time(dt, lang="nl-nl", speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=True), "negentien uur veertig") self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True, use_ampm=False), "negentien uur veertig") dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, lang="nl-nl", use_24hour=True), u"één uur vijftien") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt, lang="nl-nl"), u"vijfentwintig voor twee") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt, lang="nl-nl"), u"kwart voor twee") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt, lang="nl-nl"), u"tien voor vijf") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt, lang="nl-nl"), "vijf voor zes") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, lang="nl-nl", use_ampm=True), u"half zes 's nachts")
def test_pm(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) # Verify defaults haven't changed self.assertEqual(nice_time(dt, lang="pt-pt"), nice_time(dt, "pt-pt", True, False, False)) self.assertEqual(nice_time(dt, lang="pt"), "uma e vinte e dois") self.assertEqual(nice_time(dt, lang="pt", use_ampm=True), "uma e vinte e dois da tarde") self.assertEqual(nice_time(dt, lang="pt", speech=False), "1:22") self.assertEqual(nice_time(dt, lang="pt", speech=False, use_ampm=True), "1:22 PM") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=True), "treze e vinte e dois") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=False), "treze e vinte e dois") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="pt"), "uma em ponto") self.assertEqual(nice_time(dt, lang="pt", use_ampm=True), "uma da tarde") self.assertEqual(nice_time(dt, lang="pt", speech=False), "1:00") self.assertEqual(nice_time(dt, lang="pt", speech=False, use_ampm=True), "1:00 PM") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=True), "treze") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="pt", use_24hour=True), "treze e dois") self.assertEqual(nice_time(dt, lang="pt", use_ampm=True), "uma e dois da tarde") self.assertEqual(nice_time(dt, lang="pt", speech=False), "1:02") self.assertEqual(nice_time(dt, lang="pt", speech=False, use_ampm=True), "1:02 PM") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, lang="pt", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=True), "treze e dois") self.assertEqual( nice_time(dt, lang="pt", use_24hour=True, use_ampm=False), "treze e dois")
def test_convert_times_hu(self): dt = datetime.datetime(2017, 1, 31, 13, 22, 3) self.assertEqual(nice_time(dt, lang="hu-hu"), "egy óra huszonkettő") self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "délután egy óra huszonkettő") self.assertEqual(nice_time(dt, lang="hu-hu", speech=False), "1:22") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_ampm=True), "1:22 PM") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True), "13:22") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True, use_ampm=True), "13:22") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=True), "tizenhárom óra huszonkettő") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=False), "tizenhárom óra huszonkettő") dt = datetime.datetime(2017, 1, 31, 13, 0, 3) self.assertEqual(nice_time(dt, lang="hu-hu"), "egy óra") self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "délután egy óra") self.assertEqual(nice_time(dt, lang="hu-hu", speech=False), "1:00") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_ampm=True), "1:00 PM") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True), "13:00") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True, use_ampm=True), "13:00") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=True), "tizenhárom óra") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=False), "tizenhárom óra") dt = datetime.datetime(2017, 1, 31, 13, 2, 3) self.assertEqual(nice_time(dt, lang="hu-hu"), "egy óra kettő") self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "délután egy óra kettő") self.assertEqual(nice_time(dt, lang="hu-hu", speech=False), "1:02") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_ampm=True), "1:02 PM") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True), "13:02") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True, use_ampm=True), "13:02") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=True), "tizenhárom óra kettő") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=False), "tizenhárom óra kettő") dt = datetime.datetime(2017, 1, 31, 0, 2, 3) self.assertEqual(nice_time(dt, lang="hu-hu"), "tizenkét óra kettő") self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "éjjel tizenkét óra kettő") self.assertEqual(nice_time(dt, lang="hu-hu", speech=False), "12:02") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_ampm=True), "12:02 AM") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True), "00:02") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True, use_ampm=True), "00:02") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=True), "nulla óra kettő") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=False), "nulla óra kettő") dt = datetime.datetime(2017, 1, 31, 12, 15, 9) self.assertEqual(nice_time(dt, lang="hu-hu"), "tizenkét óra tizenöt") self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "délután tizenkét óra tizenöt") self.assertEqual(nice_time(dt, lang="hu-hu", speech=False), "12:15") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_ampm=True), "12:15 PM") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True), "12:15") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True, use_ampm=True), "12:15") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=True), "tizenkét óra tizenöt") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=False), "tizenkét óra tizenöt") dt = datetime.datetime(2017, 1, 31, 19, 40, 49) self.assertEqual(nice_time(dt, lang="hu-hu"), "hét óra negyven") self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "este hét óra negyven") self.assertEqual(nice_time(dt, lang="hu-hu", speech=False), "7:40") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_ampm=True), "7:40 PM") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True), "19:40") self.assertEqual( nice_time(dt, lang="hu-hu", speech=False, use_24hour=True, use_ampm=True), "19:40") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=True), "tizenkilenc óra negyven") self.assertEqual( nice_time(dt, lang="hu-hu", use_24hour=True, use_ampm=False), "tizenkilenc óra negyven") dt = datetime.datetime(2017, 1, 31, 1, 15, 00) self.assertEqual(nice_time(dt, lang="hu-hu", use_24hour=True), "egy óra tizenöt") dt = datetime.datetime(2017, 1, 31, 1, 35, 00) self.assertEqual(nice_time(dt, lang="hu-hu"), "egy óra harmincöt") dt = datetime.datetime(2017, 1, 31, 1, 45, 00) self.assertEqual(nice_time(dt, lang="hu-hu"), "egy óra negyvenöt") dt = datetime.datetime(2017, 1, 31, 4, 50, 00) self.assertEqual(nice_time(dt, lang="hu-hu"), "négy óra ötven") dt = datetime.datetime(2017, 1, 31, 5, 55, 00) self.assertEqual(nice_time(dt, lang="hu-hu"), "öt óra ötvenöt") dt = datetime.datetime(2017, 1, 31, 5, 30, 00) self.assertEqual(nice_time(dt, lang="hu-hu", use_ampm=True), "reggel öt óra harminc")