Decidability results for metric and layered temporal logics