dst

Determine if daylight saving time is active? SQL Server

人盡茶涼 提交于 2019-12-02 10:09:39
问题 I have a table with users, UTC time offset, and if they observe daylight saving time. Is there a built in way to get the correct user time? 回答1: Right now I'm doing this: SELECT CASE USEDAYLIGHTSAVING WHEN 1 THEN CASE DATEDIFF(HH,GETUTCDATE(),GETDATE()) -- I know the server is set to Mountan time and follows daylight saving time -- MDT = -6 -- MST = -7 WHEN -6 THEN DATEADD(HH,TIMEZONEOFFSET+1,GETUTCDATE()) ELSE DATEADD(HH,TIMEZONEOFFSET,GETUTCDATE()) END ELSE DATEADD(HH,TIMEZONEOFFSET

Detect if a date is in Daylight saving time in MySql

不羁岁月 提交于 2019-12-02 08:54:30
问题 I have inherited a legacy application where all the dates and times are stored in the local timezone (UK). I am not in a position to change how these are stored. However, the requirement is to display all the dates in GMT within the app. Therefore when I retrieve a list of events from the database I need it to display them all in this time format whilst observing if daylight saving is in operation for each particular event date. Using the following logic I can determine if daylight saving is

How to change Heroku daylight saving setting

懵懂的女人 提交于 2019-12-02 08:28:57
I could manage to change time zone on Heroku but still it is giving one hour less than my local time. Can anyone help on how to set DST (daylight saving) offset on Heroku? Heroku apps run on a normal unix system, and you have all the zoneinfo files there. I'm also fairly sure they're up-to-date. As far as unix goes, you should be able to set your TZ env var with something like: $ heroku config:set TZ=Europe/Berlin You can see the valid zoneinfo names with: $ heroku run find /usr/share/zoneinfo/posix Generally speaking, though, you'll want to run your application on an UTC environment, and

Determine if daylight saving time is active? SQL Server

允我心安 提交于 2019-12-02 06:01:51
I have a table with users, UTC time offset, and if they observe daylight saving time. Is there a built in way to get the correct user time? Right now I'm doing this: SELECT CASE USEDAYLIGHTSAVING WHEN 1 THEN CASE DATEDIFF(HH,GETUTCDATE(),GETDATE()) -- I know the server is set to Mountan time and follows daylight saving time -- MDT = -6 -- MST = -7 WHEN -6 THEN DATEADD(HH,TIMEZONEOFFSET+1,GETUTCDATE()) ELSE DATEADD(HH,TIMEZONEOFFSET,GETUTCDATE()) END ELSE DATEADD(HH,TIMEZONEOFFSET,GETUTCDATE()) END FROM USERS It works but if the server get's moved to another timezone or doesn't fallow daylight

How to get correct number of hours between Joda dates?

扶醉桌前 提交于 2019-12-02 05:06:57
问题 I want to get all the Daylight Saving Time (DST) hours between two dates. This is my example code: public static void main(String[] args) { Date startDate = new Date(); Calendar startCalendar = Calendar.getInstance(); startCalendar.setTime(startDate); startCalendar.set(2014, 2, 1, 0, 0, 0); startCalendar.set(Calendar.MILLISECOND, 0); Date endDate = new Date(); Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(endDate); endCalendar.set(2014, 2, 31, 0, 0, 0); endCalendar.set

c++ clock_gettime() and daylight savings

好久不见. 提交于 2019-12-02 04:36:45
问题 I am using clock_gettime() in my C++ program to get the current time. However, the return value is seconds since epoch in UTC. This code can get messed up in my time zone during daylight savings when the time shifts by one hour. The system itself has NTP syncing it to always give the correct time in EST. Is there a way to get clock_gettime() to report the local time instead of UTC so I can avoid the daylight savings issue? 回答1: Realize that time also reports seconds since the beginning of

CRM 2011, Date in plugin and DST

妖精的绣舞 提交于 2019-12-02 04:15:37
问题 I have one issue which I resolved by myself but yet need some confirming words whether I am 100% correct on my thought, just because there is not any documentation I found to prove myself correct. My server is in DST time currently, CRM UI is also showing 1 hour up then data stored in db. that's fine. When I calculate and store date with plugin, after my plugin update operation finishes, CRM platform deducts 1 hour from data I saved. I have read that when we do some operation via SDK related

Why doesn't C# detect that 1970/1/1 was under BST?

半腔热情 提交于 2019-12-02 03:30:28
I'm working with a 3rd party API that returns Time of Day values as DateTime values filling in Jan 1, 1970 as the date part. So for 5AM, it will return something like 1969-12-31T21:03:00.000-08:00 The problem is that, when if the user was on London time, C# fails to apply BST adjustment for 1970-01-01. For example, 1970-01-01 5AM in UTC should be 1970-01-01 6AM in London. See conversion But, C# doesn't seem to apply this conversion: var utcTime = new DateTime(1970, 1, 1, 5, 0, 0, DateTimeKind.Utc); var britishZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time"); var ukTime =

Detect if a date is in Daylight saving time in MySql

孤街醉人 提交于 2019-12-02 03:01:08
I have inherited a legacy application where all the dates and times are stored in the local timezone (UK). I am not in a position to change how these are stored. However, the requirement is to display all the dates in GMT within the app. Therefore when I retrieve a list of events from the database I need it to display them all in this time format whilst observing if daylight saving is in operation for each particular event date. Using the following logic I can determine if daylight saving is active within the query: IF(CAST(TIMEDIFF(NOW(), UTC_TIMESTAMP()) AS SIGNED) >0, DATE_FORMAT(CONVERT_TZ

DateTime.ParseExact ignore first char C#

牧云@^-^@ 提交于 2019-12-02 02:33:21
问题 I get a string value from a device like " 1140421164500 ". I have to convert it to DateTime type. I want to use DateTime.ParseExact function. I know that I can convert it by omitting the first char manually like the following: DateTime.ParseExact("140421164500", "yyMMddHHmmss", CultureInfo.InvariantCulture); But I want to avoid omitting the first char manually. I want to ignore it with a wildcard char in ParseExact function like: DateTime.ParseExact("1140421164500", "*yyMMddHHmmss",