電車が出るまで何か食べる時間があるぞ
There is time to eat something until your train leaves.
My English translation sounds rather unnatural. We would normally say "There is time to eat something before your train leaves". As such, I would have written 電車が出る前に... for the Japanese sentence.
Are both まで and 前に correct here? If so, why does まで work in this sentence?