improve datetime label generation logic