Reputation: 49
I need to parse date\time from string in russian.
Example: 14:24, 19 мая 2019
.
Upvotes: 2
Views: 647
Reputation: 691
I'd say Time.parse("14:24, 19 мая 2019")
should work for you ;)
(In case if you're using rails)
Yep, it cannot parse not English names of the months, so it should be used like here:
RUSSIAN_MONTH_NAMES_SUBSTITUTION = { 'мая' => 'may', 'июня' => 'june' }
def russian_to_english_date(date_string)
date_string.gsub(/мая|июня/, RUSSIAN_MONTH_NAMES_SUBSTITUTION)
end
Time.strptime(russian_to_english_date("14:24, 19 июня 2019"), "%H:%M, %d %B %Y")
# or
Time.parse(russian_to_english_date("14:24, 19 июня 2019"))
Upvotes: 3