有没有一个很好的理由存储时间不在UTC? [英] Is there ever a good reason to store time not in UTC?

查看:103
本文介绍了有没有一个很好的理由存储时间不在UTC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有什么好的理由在UTC(GMT)任何其他地方存储时间信息?我相信这是所有软件工程的坚实规则。到本地时间的转换只是在UI层发生的用于显示的翻译。我还看到需要进行翻译才能正确实现算法(用于处理午夜日期更改等)的情况。

解决方案

一般来说,我觉得最好使用UTC。
有时您可能需要当地时间。那么我宁愿随着UTC +时区信息一起去。



在一般情况下,对于重复的事​​件来说,这可能非常棘手,你应该非常仔细地分析用例。 >

想像一下周一的会议,每周二上午9:00。
如果DST发生变化,会议应该仍然在(新)上午9:00。



但是没有添加到法国的一些人的会议。对他们来说,会议是在下午6点。
他们用不同的规则更改DST。



当您更改DST时,他们不会,所以一段时间(直到法国更改DST)有人应该关闭:您的会议将在上午10点,他们将在下午6点停留,或保持你的上午9点,并在下午5点移动他们。没有其他方法,电脑与它无关。



应用程序将如何决定谁应该固定?
是大多数成员的组? (1个人在美国vs 20在法国?)还是关于这个人的重要性? (如果美国的一个人是CEO,那怎么办?)



你如何存储这些信息?
我的最佳解决方案是使用UTC +一个主时区
主时区中的用户赢(保持固定)。



<事情可以变得非常棘手,但是一般来说,我发现UTC解决了比引入更多的探头。


I am wondering if there are any good reasons to ever store time information in anything other that UTC (GMT)? I believe that this is a solid rule for all software engineering. The conversion to local time is merely a translation that happens at the UI layer for display purposes. I have also seen cases where the translatation is needed in order to implement an algorithm correctly (for handling midnight date changes, etc.).

解决方案

In general it I find it better to use UTC. Sometimes you might need a local time. Then I would rather go with UTC + timezone information.

In general times can be extremely tricky for repetitive events, and you should very carefully analyze the use cases.

Imagine a recurring meeting, every Tuesday at 9:00 am. If the DST changes, the meeting should still happen at (the new) 9:00am.

But no add to the meeting some guys in France. For them the meeting is at 6:00pm. And they change the DST by a different rule.

When you change the DST, they don't, so for a while (until France changes DST) someone should be "off": either your meeting will be at 10am that theirs will stay at 6pm, or keep yours at 9am and move theirs at 5pm. There is no other way, computers have nothing to do with it.

How will an application decide who should be "fixed"? Is it the group with most members? (1 guy in US vs 20 in France?) Or is it about the importance of the person? (what if the 1 guy in US is the CEO?)

How do you store that info? My best solution is to use UTC + one "master time zone" The users in the "master time zone" win (stay fixed).

Things can get pretty tricky, but in general I have found the UTC solves more probelems than it introduces.

这篇关于有没有一个很好的理由存储时间不在UTC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆