youtube streaming api time zone - youtube-api

we use Youtube API to schedule streaming on a website we create. It works fine except that we don't have the correct time zone even if we respect time format in ISO 8601, it steel is the california time zone (we are in France).
Any thought ?
Thanks
J

Related

YouTube - What effect does the scheduledStartTime have?

I have a LiveBroadcast and have added a scheduledStartTime in the future. As far as I can tell from testing this time doesn't have an effect on the overall state of the LiveBroadcast i.e. if the broadcast has a lifeCycleState of ready/testing it does not transition to live at the time set as the scheduledStartTime.
Can anyone tell me what effect the scheduledStartTime has on the Live Broadcast (or any other entity?)
Cheers
Deepak
Here's an answer from the official docs, in file resource:
snippet.scheduledStartTime datetime The date and time that the
broadcast is scheduled to start. The value is specified in ISO 8601
(YYYY-MM-DDThh:mm:ss.sZ) format.

UTC and DST for past and future events

I'm working on a system that will be used in a single time zone only, but integrates with other systems that exposes dates and times in UTC, so we thought that we go UTC all the way as well. We've also heard from before that storing your times in UTC is the way to go anyway, so it felt like the easiest path to minimize troubles.
Recently though, we ran into some trouble. We are logging events in the system which are of value to the user, so we let the user search and view them. Sweden is in a +1 timezone so an event at 0900 local time will be stored as 0800 UTC time. When showing the events to the user we can successfully transform them back to local time until very recently when daylight savings kicked in. Translating 0800 UTC to local time will now add 2 hours. The logged event now appears to have happened at 10:00. How should I handle this?
In this case, where the stored time is the same time as the time it was actually saved to DB, I could just look at the date and adjust it depending on if DST was on or off at that particular time. However, I think I need a generic solution for this, since there will be timestamps created at various times (at other places) in the system that need to represent future and past points in time. To me it looks like I have 2 options.
Go back to storing local times and just do some extra work when I integrate with other systems that use UTC.
Along with each UTC timestamp store some data that can tell me if a timestamp was created during DST or not.
Am I wrong? Right? Missing something?
You can always get the client timezone offset using the getTimezoneOffset method. Now all that's left is to apply this timezone offset to the UTC date stored in your database and display the correct date to the end user. If on the other hand you need to display the timezone offset used by the user when the event was recorded in your database then you definitely an additional column in your DB to record this offset. Things get tricky when you want to handle multiple timezones: what happens when you want to display a record to a user in India that was submitted by a user in Sweden?
The main thing you are missing is that you cannot just think of Sweden as a +1 time zone. A time zone and a time zone offset are two very different things. Read the timezone tag wiki for more details on this.
Instead, you can take one of the two following approaches:
Think about the time zone in terms of it's IANA tzdb identifier. For Sweden, use Europe/Stockholm. Do your conversions between UTC and local time using this time zone, using a language, library, or platform that implements the tz database.
Instead of figuring out what the client-side time zone is, rely on the client-side operating system to do the conversions to local time. Most environment (including JavaScript in a web browser) can convert from UTC to local time and vice-versa. With this approach, transmit only UTC times between the client and the server.
Also, you didn't ask in the question, but in your title you mentioned future events. That is a very different scenario, and often requires you capture the local time and IANA time zone. See this answer for more details.
You may also wish to read Daylight saving time and time zone best practices.

Time Zone Calculation

Am developing website like online travel portal. The issue is displaying GMT time for various regions at flight booking and list out the timing. Any one gives idea to calculate and show the time for different countries?
Thanks
Although it is pretty hard to answer your question without a reference to particular technology, I will try.
End user Time Zone detection
Definitely, all time-related information should be presented both in local format and local time zone. By local I mean the one used by end user.
I am guessing that your application will not require creating user profiles. I am also assuming that flight schedules will not be visible on front page and user would need to perform search. In that case you have three choices:
Let user specify time zone from drop down box. I have no way to show you how it should be done without referring to concrete technology. The only thing I must point out is, it should present UTC offset, time zone name and list of cities, for example: UTC+01:00 Central European Time (Paris, Berlin, Warsaw).
You could read current time zone offset with JavaScript and send it out to server
In that case you can use following code snippet to detect offset:
var now = new Date();
var offset = now.getTimezoneOffset();
This will give you current GMT offset in minutes. The problem with that solution is, this offset might be different on the target date.
Obviously you could as well send GMT based dates in invariant form to the browser (for example using ISO8601 format: 2011-05-25T11:07Z) and format this date on the client using JavaScript. I never heard of for example JQuery plugin which would do that correctly (respecting local formats), though. It seems that you would be forced to write your own.
Date and time formatting as well as time zone conversion
Ha, it depends on solution you want to implement as well as technology you want to use. For now, I can't write much here.

Web application date time localization best practice at 201x

I have worked for various web projects but correct date time localization have not been done and considered throroughly so I want to ask this very typical problem here and I want to hear comments from expert in this problem
What is the correct strategy for storing a date/time value from client from server
As I understand, because of locale and timezone so we have to do the conversion, I have heard about GMT or UTC time and after do some search it seems that UTC is more accurate ? so we will convert from client time -> UTC+0 when saving and when we read the value from server to client, we convert from server time back to client time again ?
However, I see in some website, at the bottom have the sentence "All times are in UTC", "All times are in GMT" and also "All times are in your local time". So maybe not all the sites do the convertion back and forth ? And in that case the user has to manually do the date/time conversion ?
How to display the date/time convenient to user based on his locale and region
How to provide personalization on date/time value ? I had one time depends on vbscript to do the display and the format is read from windows regional and format settings automatically. But without vbscript how can we determine a date/time pattern for a user of a specific locale. Do we have to store a mapping between a locale and pattern somewhere and do the conversion at the server side ?
Although date/time conversion is needed in most case, there's situation where only date matter for example if my birthday is 2 Feb 1980, it should be the same for all locale and no conversion should be done. How can we address this issue.
Storing the dates in UTC is always better. While displaying to user, convert it to local time and display

Where can I find a good introduction to timezones

I have to write some code working with timezones. Is there a good introduction to the subject to get me started?
Also answered at What every developer should know about time (which includes the referenced screenshots).
With daylight savings time ending today, I thought this was a good time for a post. How to handle time is one of those tricky issues where it is all too easy to get it wrong. So let's dive in. (Note: We learned these lessons when implementing the scheduling system in Windward Reports.)
First off, using UTC (also known as Greenwich Mean Time) is many times not the correct solution. Yet many programmers think if they store everything that way, then they have it covered. (This mistake is why several years ago when Congress changed the start of DST in the U.S. you had to run a hotfix on Outlook for it to adjust reoccurring events.)
So let's start with the key question – what do we mean by time? When a user says they want something to run at 7:00 am, what do they mean? In most cases they mean 7:00 am where they are located – but not always. In some cases, to accurately compare say web server statistics, they want each "day" to end at the same time, unadjusted for DST. At the other end, someone who takes medicine at certain times of the day and has that set in their calendar, will want that to always be on local time so a 3:00pm event is not 3:00am when they have travelled half way around the world.
So we have three main use cases here (there are some others, but they can generally be handled by the following):
1.The same absolute (for lack of a better word) time.
2.The time in a given time zone, shifting when DST goes on/off (including double DST which occurs in some regions).
3.The local time.
The first is trivial to handle – you set it as UTC. By doing this every day of the year will have 24 hours. (Interesting note, UTC only matches the time in Greenwich during standard time. When it is DST there, Greenwich and UTC are not identical.)
The second requires storing a time and a time zone. However, the time zone is the geographical zone, not the present offset (offset is the difference with UTC). In other words, you store "Mountain Time," not "Mountain Standard Time" or "Mountain Daylight Savings Time." So 7:00 am in "Mountain Time" will be 7:00 am in Colorado regardless of the time of year.
The third is similar to the second in that it has a time zone called "Local Time." However, it requires knowing what time zone it is in in order to determine when it occurs.
Outlook now has a means to handle this. Click the Time Zones button:
And you can now set the time zone for each event:
When I have business trips I use this including my flight times departing in one zone and arriving in another. Outlook displays everything in the local timezone and adjusts when that changes. The iPhone on the other hand has no idea this is going on and has everything off when I'm on a trip that is in another timezone (and when you live in Colorado, almost every trip is to another timezone).
Putting it to use
Ok, so how do you handle this? It's actually pretty simple. Every time needs to be stored one of two ways:
1.As UTC. Generally when stored as UTC, you will still set/display it in local time.
2.As a datetime plus a geographical timezone (which can be "local time").
Now the trick is knowing which to use. Here are some general rules. You will need to figure this out for additional use cases, but most do fall in to these categories.
1.When something happened – UTC. This is a singular event and regardless of how the user wants it displayed, when it occurred is unchangeable.
2.When the user selects a timezone of UTC – UTC.
3.An event in the future where the user wants it to occur in a timezone – datetime plus a timezone. Now it might be safe to use UTC if it will occur in the next several months (changing timezones generally have that much warning - although sometimes it's just 8 days), but at some point out you need to do this, so you should do it for all cases. In this case you display what you stored.
4.For a scheduled event, when it will next happen – UTC. This is a performance requirement where you want to be able to get all "next events" where their runtime is before now. Much faster to search against dates than recalculate each one. However, this does need to recalculate all scheduled events regularly in case the rules have changed for an event that runs every quarter.
1.For events that are on "local time" the recalculation should occur anytime the user's timezone changes. And if an event is skipped in the change, it needs to occur immediately.
.NET DateTime
Diving in to .NET, this means we need to be able to get two things which the standard library does not provide:
1.Create a DateTime in any timezone (DateTime only supports your local timezone and UTC).
2.For a given Date, Time, and geographical timezone, get the UTC time. This needs to adjust based on the DST rules for that zone on that date.
Fortunately there's a solution to this. We have open sourced out extensions to the DateTime timezone functionality. You can download WindwardTimeZone here. This uses registry settings in Windows to perform all calculations for each zone and therefore should remain up to date.
Browser pain
The one thing we have not figured out is how to know a user's location if they are using a browser to hit our web application. For most countries the locale can be used to determine the timezone – but not for the U.S. (6 zones), Canada, or Russia (11 zones). So you have to ask a user to set their timezone – and to change it when they travel. If anyone knows of a solution to this, please let me know.
Update: I received the following from Justin Bonnar (thank you):
document.getElementById('timezone_offset').value = new Date().getTimezoneOffset();
Using that plus the suggestion of the geo location for the IP address mentioned below will get you close. But it's not 100%. The time offset does not tell you if you for example if you are in Arizona (they & Hawaii do not observer daylight savings time) vs Pacific/Mountain (depending on DST) time zone. You also depend on javascript being on although that is true for 99% of the users out there today.
The geo location based on IP address is also iffy. I was at a hotel in D.C. when I got a report of our demo download form having a problem. We pre-populate the form with city, state, & country based on the geo of the IP address. It said I was in Cleveland, OH. So again, usually right but not always.
My take is we can use the offset, and for cases where there are multiple timezones with that offset (on that given day), follow up with the geo of the IP address. But I sure wish the powers that be would add a tz= to the header info sent with an HTML request.

Resources