Skip to content

Commit

Permalink
Parse negative numbers in Acuant birthdays (#4178)
Browse files Browse the repository at this point in the history
**Why**: these are how timestamps before the Unix epoch
are encoded
  • Loading branch information
zachmargolis authored Sep 10, 2020
1 parent 697dd56 commit 19ebc9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/doc_auth/acuant/pii_from_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call
hash
end

ACUANT_TIMESTAMP_FORMAT = %r{/Date\((?<milliseconds>\d+)\)/}.freeze
ACUANT_TIMESTAMP_FORMAT = %r{/Date\((?<milliseconds>-?\d+)\)/}.freeze

# @api private
def convert_date(date)
Expand Down
4 changes: 4 additions & 0 deletions spec/services/doc_auth/acuant/pii_from_doc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
expect(pii_from_doc.convert_date('/Date(449625600000)/')).to eq('04/01/1984')
end

it 'parses and formats negative numbers' do
expect(pii_from_doc.convert_date('/Date(-985824000000)/')).to eq('10/06/1938')
end

it 'is nil for a bad format' do
expect(pii_from_doc.convert_date('/Foobar(111111)/')).to eq(nil)
end
Expand Down

0 comments on commit 19ebc9c

Please sign in to comment.