improved date key mapping function