dst

How to know whether a country is using Daylight Saving Time using JavaScript?

∥☆過路亽.° 提交于 2019-12-20 03:39:11
问题 I'm in China and I've a friend who is in other countries. e.g. UK, USA, New Zealand... I know his country's name in English and time zone there. But how can I know whether his country is using DST now or not? Any ideas? Thank you! 回答1: Here is an example using JSONP and some Yahoo services: function jsonp(src){ var s = document.createElement('script'); s.charset = 'UTF-8'; document.body.appendChild(s); s.src = src; } function getLocation(where){ var src = 'http://query.yahooapis.com/v1/public

How to tell if it's British Summer Time

孤街醉人 提交于 2019-12-20 02:46:07
问题 I have the following code, which should return an offset of 60 (to show that in the UK at present, we are in British Summer Time - ie. 60 minutes ahead of GMT): var info = TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time"); DateTimeOffset localServerTime = DateTimeOffset.Now; double off = localServerTime.Offset.TotalMinutes; return off; However, it returns 0. Could anyone please help fix this for me? 回答1: Use TimeZoneInfo.IsDaylightSavingTime Method (DateTimeOffset) to find if it

Strange behavior formatting moment.js date

纵然是瞬间 提交于 2019-12-19 20:36:11
问题 We are tracking down a bug in our application that seemingly is related to moment.js formatting. Here's the problematic call (reproduced in Chrome, FF, and Edge, for reference): moment('2016-03-13T23:59:59.999-06:00').format('YYYY-MM-DD') What we expect: 2016-03-13 What we get: 2016-03-14 This seemingly has something to do with daylight savings time as this is the only date (so far) that we've been able to reproduce this incorrect behavior on and DST flipped on that day. If we switch the UTC

Get the next date/time at which a daylight savings time transition occurs

本小妞迷上赌 提交于 2019-12-19 14:25:20
问题 I would like to write (or use if it already exits) a function in C# that returns the date/time of the next DST transition given a System.TimeZoneInfo object and a particular "as of" time in that time zone. The time returned should be in the provided time zone. The function I want has this signature: public DateTime GetNextTransition(DateTime asOfTime, TimeZoneInfo timeZone) { // Implement me! } For example, if I pass in the "Eastern Standard Time" TimeZoneInfo object, and 1/21/2011@17:00 as

problems with Java daylight savings time

ぐ巨炮叔叔 提交于 2019-12-19 01:46:42
问题 I have a Java app that needs to be cognizant of the time zone. When I take a Unix epoch time and try to convert it into a timestamp to use for an Oracle SQL call, it is getting the correct timezone, but the timezone "useDaylightTime" value is not correct, i.e., it is currently returning "true", when we are NOT in DST (I am in Florida in TZ "America/New_York"). This is running on Red Hat Linux Enterprise 6, and as far as I can tell, it is correctly set up for the timezone, e.g. 'date' returns:

Get Daylight Saving Transition Dates For Time Zones in C

十年热恋 提交于 2019-12-18 13:17:17
问题 In C, is there a simple, cross-platform way of retrieving the dates that a given timezone begins and ends daylight saving? I already have timezone offset information and whether or not daylight savings is currently being observed, but I really need the dates at which daylight savings begins and ends (for an external dependency I don't control). In Windows, I'm using GetTimeZoneInformation to get TimeZoneInfo, but I can't find a similar function for Linux/Solaris/Mac. I should point out also

Why does this rails query behave differently depending on timezone?

南楼画角 提交于 2019-12-18 11:34:04
问题 I have a rails time-based query which has some odd timezone sensitive behaviour, even though as far as I know I'm using UTC. In a nutshell, these queries give different answers: >> Model.find(:all,:conditions=>['created_at<=?',(Time.now-1.hours).gmtime]).length => 279 >> Model.find(:all,:conditions=>['created_at<=?',(Time.now-1.hours)]).length => 280 Where the DB actually does contain one model created in the last hour, and the total number of models is 280. So only the first query is correct

How to detect change of system time in Linux?

ε祈祈猫儿з 提交于 2019-12-18 06:23:31
问题 Is there a way to get notified when there is update to the system time from a time-server or due to DST change? I am after an API/system call or equivalent. It is part of my effort to optimise generating a value for something similar to SQL NOW() to an hour granularity, without using SQL. 回答1: You can use timerfd_create(2) to create a timer, then mark it with the TFD_TIMER_CANCEL_ON_SET option when setting it. Set it for an implausible time in the future and then block on it (with poll/select

JavaScript, time zones, and daylight savings time

↘锁芯ラ 提交于 2019-12-18 06:13:09
问题 Welcome to this week's episode of Yet Another Time Zone Question : I've done a fair bit of reading on SO, tried to manipulate moment.js and date.js into helping me, and generally been plagued by a feeling of frustration since I started trying to solve this, so if someone could help or point me at the duplicate question on SO that I just haven't been able to find, that'd be awesome. I have a page. This page displays a series of times, e.g.: 7:28, 7:38, 7:48. I know whether these are AM/PM.

PHP Daylight savings conundrum

不想你离开。 提交于 2019-12-18 05:53:51
问题 I have a general question about dealing with daylight saving time. I guess its not really PHP specific, but I am writing in PHP, so I figure it wouldn't hurt to include it. I have a calendar app built using jquery fullcalendar. The user views events in their local timezone and my server stores them as UTC datetimes in mysql. (Other questions on stackoverflow suggest that this is the best way to deal with timezones.) So there is a conversion every time the user saves or views events on the