I needed to convert a timestamp (seconds, minutes, hours, day, month, last 2 digits of the year) into a BCD string of bytes. Here’s the Perl sub I came up with to do that:
sub bcd_timestamp_string (@) {
# Convert given time or local time to BCD bytes
my @time = @_ ;
join('', map {
pack('H*',sprintf('%02d',$_))
} @time) ;
}
Copyright © 2002-2006 James (Jim) R. R. Service (@gmail.com - jservice)