TSQL / .NET - 用于存储用户的时区的最佳做法 [英] Best practices for storing user time zone - TSQL/.Net

查看:160
本文介绍了TSQL / .NET - 用于存储用户的时区的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要跟踪用户的时区,其信息(或不处理),处理可以在特定时间发生,他们指定(在他们自己的时区)。

I have a need to track user's time zone so processing of their information (or no processing) can happen at specific times they specify (in their own time zone).

答案显然是存储的时区与他们的个人资料信息的用户数据库。这是一个有点棘手的事情是夏令时。从这个图像下方的最北部和南部地区注意使用夏令时的偏移量。因此,存储时区偏移犯规觉得它会工作,因为这可能会抵消改变通过一年。相反,我在考虑存储时区code(像PST),让标准时库查找偏移的。

The obvious answer is to store the time zone in the user database with their profile information. The thing that is a little tricky is daylight savings. Notice from this image below that most northern and southern regions use a daylight time offset. So storing a time zone offset doesnt feel like it will work, since that offset could change through the year. Instead I'm thinking of storing the time zone code (something like PST) and letting a standard time library lookup the offset.

所以,有两件事情我想的都是:

So a couple things I'm thinking about are:

1)是否TSQL具有这个库,用于从时区code(PST)转换成电流UTC偏差? 2)我知道 .NET可以做到这一点,但我preFER要做到这一点,在因为该数据库就是我的查询将运行。

1) Does TSQL have this library for converting from a time zone code (PST) to a current UTC offset? 2) I know .net can do this, but I'd prefer to do this in the database since that's where my queries will run.

推荐答案

找到什么样子了的看好NET库。这其中在建净之一的好处是,你可以通过在磁盘上删除一个新副本更新时区数据库。使用.NET一个你必须等待新的编译版本。 (不过时区变化很可能是罕见的)的。

Found what looks like a promising .Net library. The advantage of this one over the built in .Net one is that you can update the timezone database by dropping a new copy on disk. With the .Net one you have to wait for new compiled release. (however time zone changes are probably rare).

这篇关于TSQL / .NET - 用于存储用户的时区的最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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