X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=cards%2Fnew_card.sh;h=424f242904f027d46787a0e033cd488662bb71e7;hp=1e37b7001af3c84a86d25409cdc8e81bc3e272ed;hb=be9ce34edbd0d4305f438ba46883377597789ec1;hpb=1227cb42309bc7edd296e8fea288f68968b1e003 diff --git a/cards/new_card.sh b/cards/new_card.sh index 1e37b70..424f242 100755 --- a/cards/new_card.sh +++ b/cards/new_card.sh @@ -31,13 +31,22 @@ vcf_escape(){ | sed -E ':X;$!{N;bX}; s;\n;\;;g' } -IFS='|' read -r date fn ln bmonth byear tel tcell junk1 email junk2 note <<-EOF +IFS='|' read -r date fn ln bday bmonth byear tel tcell junk1 email junk2 note <<-EOF $(POST seed |tr \\t \|) EOF [ ${#byear} = 1 ] && byear="200$byear" [ ${#byear} = 2 ] && byear="20$byear" [ ${#bmonth} = 1 ] && bmonth="0$bmonth" +[ ${#bday} = 1 ] && bday="0$bday" + +mn="" +case $fn in + *\ *) + mn="${fn#* }" + fn="${fn%% *}" + ;; +esac mkdir -p "${_DATA}/lock/vcard/" lockdir="${_DATA}/lock/vcard/${card}/" @@ -47,13 +56,13 @@ if mkdir "$lockdir"; then cat >"$lockfile" <<-EOF BEGIN:VCARD VERSION:4.0 - N:$(vcf_escape "$ln");$(vcf_escape "$fn");;; - FN:$(vcf_escape "$fn $ln") - BDAY:$(vcf_escape "${byear}-${bmonth}-01") + N:$(vcf_escape "$ln" "$fn" "$mn" "" "") + FN:$(vcf_escape "${fn}${mn:+ }${mn} ${ln}") + BDAY:$(parse_date "${byear}-${bmonth}-${bday}") TEL:$(vcf_escape "$tel") TEL;TYPE=CELL:$(vcf_escape "$tcell") EMAIL:$(vcf_escape "$email") - X-ZACK-JOINDATE:$(vcf_escape "$date") + X-ZACK-JOINDATE:$(parse_date "$date") ADR: NOTE:$(vcf_escape "$note") UID:${uid}