我正在将GTFS提要存储到SQL数据库中,并且预计某些时间会存储在时间值上限24:00:00之上。例如,某些火车在上午12:30开行,但已列出前几天的服务,在GTFS规范中,该行车时间存储为24:30。
I'm storing GTFS feeds into a SQL database and some times are expected to be stored above the 24:00:00 cap on time values. For example, some trains run at 12:30AM, but are listed for the previous days service, and that running time is stored as 24:30 in the GTFS specifications.
解决这个问题的最佳方法是什么?我应该只将它存储为字符串吗?
What would be the best way of getting around this? Should I just store it as a string?
推荐答案建议为此使用int ...您的值可能是:
Suggest to use int for that... your value could be:
Sec + Min * 60 + Hour * 3600对于24:30:00,您将获得88200。
For the 24:30:00, you will get 88200.
从数据库加载您的值时,您可以反转您的值通过简单的数学方程式:
When loading your value from DB, you could reverse your value by simple math equation:
Hour = int(value / 3600) Min = int(value % 3600 / 60) Sec = value % 3600 % 1800更多推荐
在Postgresql中将时间存储在24:00:00以上的最佳方法?
发布评论