1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-17 11:54:22 +01:00

[bug] fablab:fix_invoices date parsing error

This commit is contained in:
Sylvain 2021-05-26 11:49:52 +02:00
parent 266982b24a
commit 4e601b672a
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,8 @@
# Changelog Fab-manager
- Updated ffi to 1.15.1
- Updated GitHub issue templates
- Fix a bug: fablab:fix_invoices task fails to recreate the data if the date is in english
## v4.7.10 2021 May 25

View File

@ -98,8 +98,9 @@ namespace :fablab do
description = ii.description
# DateTime.parse only works with english dates, so translate the month name
month_idx = I18n.t('date.month_names').find_index { |month| month && description.include?(month) }
description.gsub!(/#{I18n.t('date.month_names')[month_idx]}/, I18n.t('date.month_names', locale: :en)[month_idx])
unless month_idx.nil?
description.gsub!(/#{I18n.t('date.month_names')[month_idx]}/, I18n.t('date.month_names', locale: :en)[month_idx])
end
start = DateTime.parse(description)
end_time = DateTime.parse(/- (.+)$/.match(description)[1])
[start, DateTime.new(start.year, start.month, start.day, end_time.hour, end_time.min, end_time.sec, DateTime.current.zone)]