...
 
Commits (2)
......@@ -12,7 +12,7 @@
#include <libxml/HTMLparser.h>
#include <libxml/xpath.h>
#define FAC_DEBUG 1
//#define FAC_DEBUG 1
#ifdef FAC_DEBUG
//! The base URL for accessing FurAffinity.
......
......@@ -58,7 +58,17 @@ module KruzifiXML
next FavInfo.new(valid: false, fav_id: fav_id, username: username, submission_id: submission_info[:id], submission_title: submission_info[:title])
end
# parse the date without `1st / 2nd / ...` suffix into local time; FA uses EST
fav_date = Time.parse(date_node["title"].sub(/st|nd|rd|th/, ""), "%b %-d, %Y %I:%M %P", Time::Location.load("EST")).to_unix
# also work around some weird Crystal bug where it somehow parses 12:41 PM to be 24:41. wtf?
time_match = date_node["title"].scan(/(?<whole_time>(?<hours>\d{2}):(?<minutes>\d{2}) (?<ampm>AM|PM))/).first
hours = time_match["hours"].to_i
if time_match["ampm"] == "PM" && hours != 12
hours += 12
elsif time_match["ampm"] == "AM" && hours == 12
hours = 0
end
time24 = "%02d:%s" % [hours, time_match["minutes"]]
fav_date = Time.parse(date_node["title"].sub(/st|nd|rd|th/, "").sub(time_match["whole_time"], time24), "%b %-d, %Y %H:%M", Time::Location.load("EST")).to_unix
FavInfo.new(
valid: true,
......