as.fmt function

Generic casting method for formats