Skip to content

Commit

Permalink
Add .vcf support to automtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dfandrich committed Jul 25, 2024
1 parent 4c63e97 commit ecf1ecb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
13 changes: 13 additions & 0 deletions automtime
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,15 @@ mtime_vbox () {
TIME=$(normalize_iso_time "$RAWTIME")
}

# File type: vcf (vCard contact)
mtime_vcf () {
RAWTIME=$(sed -E -n -e 's/^REV:([^()]*)(\(.*\))?$/\1/p' <"$1" | sort | tail -1)
# $RAWTIME is like 2017-05-10T14:34:50Z
if [ -n "$RAWTIME" -a "$RAWTIME" != "0" ]; then
TIME=$(normalize_iso_time "$RAWTIME")
fi
}

# File type: warcgz (Compressed Web Archive Collection file)
mtime_warcgz () {
# Look for the WARC-Date: lines only within the WARC header sections
Expand Down Expand Up @@ -1208,6 +1217,10 @@ for f in "$@" ; do
TYPE=vbox
;;

*.vcf)
TYPE=vcf
;;

*.warc.gz)
TYPE=warcgz
;;
Expand Down
1 change: 1 addition & 0 deletions test-automtime-expected
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'testfiles/type1.tgz' '2021-10-14 20:36:00 +0000'
'testfiles/type1.tiff' '2009-10-11 12:13:14'
'testfiles/type1.ttf' '2021-10-17'
'testfiles/type1.vcf' '2024-07-25 17:09:12 +0000'
'testfiles/type1.wacz' '2022-05-21 21:14:54'
'testfiles/type1.warc.gz' '2023-01-13 17:59:30.783 +0000'
'testfiles/type1.webm' '2023-04-05 06:07:08.0900000333786011'
Expand Down
24 changes: 24 additions & 0 deletions testfiles/type1.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BEGIN:VCARD
UID:sorted-1
N:Last;First Name
TEL;HOME:+1-212-5553789
EMAIL;TYPE=home,work:work@example.com
REV:2017-05-10T14:36:01Z(0)
END:VCARD
BEGIN:VCARD
VERSION:3.0
UID:photo-1
FN:photo
N:;photo;;;
PHOTO;TYPE="PNG";ENCODING=b:iVBORw0KGgoAAAANSUhEUgAAAAgAAAA
IAQAAAADsdIMmAAAAC0lEQVQImWNgQAUAABAAASG2FtIAAAAASUVORK5CYII=
EMAIL;TYPE=WORK:photo@example.com
REV:2024-07-25T17:09:12Z(2)
END:VCARD
BEGIN:VCARD
UID:custom-12
N:Name;A
TEL;HOME:1.800 K L 5 E R R O R
EMAIL;TYPE=home,work:example@example.com
REV:0
END:VCARD
10 changes: 10 additions & 0 deletions testfiles/type2.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BEGIN:VCARD
VERSION:3.0
EMAIL;TYPE:mail@example.com
FN:Fullname
N:ZeroRev;;;;
ORG:Organization
UID:5a535529-fd93-4448-bae3-bde1ee3ff695
X-KADDRESSBOOK-X-Profession:Professional Test Services
REV:0
END:VCARD

0 comments on commit ecf1ecb

Please sign in to comment.