Reduced the amount of duplicated code.
Reduced the amount of duplicated code.

josh-wambua/libdivecomputer,venkateshshukla/libdivecomputer,venkateshshukla/libdivecomputer,glance-/libdivecomputer,andysan/libdivecomputer,josh-wambua/libdivecomputer,henrik242/libdivecomputer,henrik242/libdivecomputer,Poltsi/libdivecomputer-vms,andysan/libdivecomputer,glance-/libdivecomputer