This commit is contained in:
BoHung Chiu 2021-03-15 14:02:04 +08:00
parent 0e0dd99de4
commit d97ce59556
1 changed files with 3 additions and 3 deletions

View File

@ -126,9 +126,9 @@ module AsiaSyncPlugin
bk.publisher_translations = localize_data(book["Books_publisher"]) #出版社
if !(book["Books_YearMonth"].blank?) #出版日期
if book["Books_YearMonth"].scan(/[\.\/]/).length == 0 # ex: 2021
bk.publish_date = DateTime.parse(book["Books_YearMonth"] + "/1")
bk.publish_date = DateTime.parse(book["Books_YearMonth"] + "/1") rescue nil
else #ex: 2017.03
bk.publish_date = DateTime.parse(book["Books_YearMonth"].gsub('.','/'))
bk.publish_date = DateTime.parse(book["Books_YearMonth"].gsub('.','/')) rescue nil
end
end
if bk.publish_date
@ -146,7 +146,7 @@ module AsiaSyncPlugin
bk.publisher_translations = localize_data(book["Books_publisher"]) #出版社
bk.year = book["Books_year"]
if !(book["Books_year"].blank?) #出版年度
bk.publish_date = DateTime.parse(book["Books_year"] + "/1")
bk.publish_date = DateTime.parse(book["Books_year"] + "/1") rescue nil
end
bk.member_profile_id = user.member_profile_id
puts "books #{bk.id} saved" if bk.save