twitter time date stamp -Which time zone is it? - twitter

I read in a post at stackoverflow about the time date stamp for tweets that
the timezone of each tweet is automatically converted to the local timezone. If you need UTC, you can use the .ToUniversalTime() method, for example:
myTweet.CreatedDate.ToUniversalTime();
I wanted to know, when I download a tweet from Twitter's streaming API, what is the time zone. In the answer above they wrote that it is converted to the local timezone. I was not sure if that is the local zone of me (the person downloading the tweet stream) or of the person sending the tweet or of some ISP or somewhere else. Could anyone clarify this?
Thanks very much.

The API stores and returns dates and times in GMT to avoid issues with clock changes.
According to this answer, you can use the utc_offset property of the user object (which is returned with the tweet) to calculate the time relative to the user's timezone.

Related

CloudKit receives and stores time correctly, returns UTC Time when queried

I send a local date to my iCloud container, but when I query it, it returns a UTC date, does anyone know how to change this?
The date also seems to be inconsistent on the dashboard. As you can see, in the data list, the time is local. When I click on it and scroll to the time property, it's UTC.
From Date documentation:
A specific point in time, independent of any calendar or time zone.
So when you are querying the Date from iCloud I am pretty sure you are getting a correct one since it is free of any time zone, so it's dependant on the formatter's locale/time zone when it comes to displaying it.
The date you seen on the record list is date formatter for the locale and timezone of your system. The date you see when you open record details is the same point in time but displayed as UTC date.
e.g. I live in Poland and my timezone is UTC+2 so for me the same Date (point in time) is displayed in the dashboard like this:

YouTube Analytics API Report.Query by Day with Timezone

I know, there is another Topic here with a similar Question, but the main Question has not been answered yet (as far as I understand).
Given, that the YouTube Analytics API is returning everything in "Pacific time zone", and I query the Data for "one Day" (via StartDate/EndDate) - the returned Data may not really make sense to me, if I need them in UTC. If the ViewCount for example comes as "800 Views" on 2017-12-24, this is 2017-12-24 in that Timezone, not the 2017-12-24 in a European Timezone (or at least UTC). SO basically, this Information is not helpfull at all to get the Amount of Views per Day from a User in a different Timezone.
How can this be corrected? Is there a Way to add a Timezone (I didnt find one), or to add a Starting/End HOUR, to get really a Day-Bucketed Collection in UTC?
Thanks,
Christoph

How to handle a DateTIme style like Saturdays at 01:05 (JST)

I'm scraping a site to get the date and time a episode comes out on. So what i'm getting is Saturdays at 01:05 (JST) which is the time in japan. I have a field in my episodes table called broadcast and it has a DateTime format.
What is the best way to handle this and to change the time zone to (pst)?
Assuming you're literally scraping the string Saturdays at 01:05 (JST) off of the website, there are a few things to consider.
First, a single DateTime field is not really going to be able to represent a recurring time, like you have. Gems like IceCube were created to handle the complexities of recurring, scheduled dates. But you can get by with one DateTime field, under the assumption that it stores one instance of the broadcast and all other broadcasts are at the same time and day every week.
Now, you need to parse the string you're scraping into that date. The easiest way to do this is with the Chronic gem, which takes all sorts of English-worded time representations and turns it into a date. With your date, you need to unpluralize "Saturdays" so that Chronic knows to just find the next Saturday:
require 'chronic'
string = "Saturdays at 1:30 (JST)"
broadcast = Chronic.parse(string.sub('days', 'day'))
The broadcast variable now holds a DateTime value which you can store directly into the database. Don't worry about the time zone -- Chronic returned a Time value with zone information, so Rails will store it into your database in UTC, and convert it back out to your server timezone whenever you load it.
If you do want to convert the time to a specific zone ever, you can do so easily:
pst_time = broadcast.in_time_zone('Pacific Time (US & Canada)')

Accounting for daylight savings in rails webapp and iCal

Right, this is a bit confusing for me, so I'm going to try and explain from the top!
I have a rails web app. It's an internal company app and will only be used in the UK.
One of the things the app does is manage meetings.
Meetings have a date & time when they start. There's a date/time picker on the form which allows the user to pick the date & time the meeting is for. I save this date AS IS into the database. All meetings last 2 hours, so the end time is simply start + 2 hours.
Example:
2013-06-23 6:45PM in the form is stored in the db as 2013-06-23 18:45:00
2013-12-23 6.45pm in the form is stored in the db as 2013-12-23 18:45:00
Note that the first date is during Daylight Savings (BST) and the second is during GMT. I don't actually care whether it is GMT or BST: the meeting happens at that time, absolutely.
Inside the rails webapp, I simply print out the exact date & time from the DB - formatted nicely, of course!
Now, at some point I send an email to the organiser of the meeting, and the person they're meeting with. This email tells them the the date & time of the meeting etc, and also includes an iCal (.ics) file for them to put into their (Outlook usually, but also Apple or gmail) calendar.
The issue I am having is that (using the above examples) Outlook shows the meetings like this:
Meeting #1: Start: 23/06/2013 7:45pm, End: 23/06/2013 9:45pm
Meeting #2: Start: 23/12/2013 6:45pm, End: 23/12/2013 8:45pm
Note that it has adjusted the first one because of the BST/GMT thing.
The text of the .ics file contains this code:
Meeting #1:
BEGIN:VCALENDAR
...
DTEND:20130623T204500Z
DTSTART:20130623T184500Z
...
END:VCALENDAR
Meeting #2:
BEGIN:VCALENDAR
...
DTEND:20131223T204500Z
DTSTART:20131223T184500Z
...
END:VCALENDAR
So I am encoding the dates/times using the Z timezone (UTC). I understand this is why Outlook mis converting the UTC time into the BST time for #1 and leaving #2 alone (because GMT == UTC)
My question is: how do I stop this happening? I want the time the meeting is scheduled for to be the absolute, actual time, regardless of GMT/BST: 6:45pm
Should I be storing the date-times as UTC in the DB? How would this be done (I assume it would apply to all dates, not just meeting start dates). And how to re-convert them back into the actual datetime when I display them in the webapp?
Extra:
I have an entry in my initializers/time_formats.rb like this:
:ical => "%Y%m%dT%H%M00Z"
So dates come out like "20130623T184500Z". I use this when building the ics. And this I think is the issue - if the date/time is during BST I don't want to be using Z, but something else?
Your problem is your date/time format. You have:
DTSTART:20130623T184500Z
in your .ics file and this corresponds to 19:45 BST (as British summer time is UTC+1).
There are a few things you should do. First, you can simply remove the 'Z' from the end of your dates. This means that the times inherit the timezone of the calendar, or the underlying application.
This will work assuming that the machines which are running Outlook are all in the Europe/London timezone. If not, or if you want to be a bit safer, you should also specify the following after your BEGIN: VCALENDAR line:
X-WR-TIMEZONE:Europe/London
This specifies the default timezone for all dates which are not specified explicitly.
Finally, if this does not work for any reason then you need to define your datetimes explicitly. First you need to add a timezone definition for Europe/London to the calendar. The info you need is available at http://www.tzurl.org/zoneinfo-outlook/Europe/London.ics. Then you need to ensure that all datetimes are of the format:
DTSTART;TZID=Europe/London:20130623T184500
This last approach is the best, as it means that if your requirements expand to other timezones you will be able to handle them relatively easily.
Sorry to answer this myself, but in case anyone else runs into this here's what I found was the cause of my particular issue. Note that the answer above re timezones also makes sense!
My rails app is storing UTC datetimes in the DB (as is default)
But, it also thought it's own timezone was UTC, which also seems to be the default.
The upshot of that is essentially it was storing local dates, local to UTC anyway. Changing the app to know it was sitting in Europe/London made it so the dates in the DB are all now accurately UTC (meaning, they're an hour off if I'm currently in BST)
I can now use the Z datetime format in iCals, and outlook and the rails app both convert the UTC date back into the actual datetime for the viewing-user's locale (Europe/London for everyone at the moment). This is what I wanted.

Twitter - Time Zone of the Tweeet

What is the time zone used for tweets in Twitter API?
The created_at field for a tweet in the Twitter REST API gives the timestamp in UTC.
If a user has configured their timezone with Twitter, the utc_offset field gives you the difference in seconds between their timezone and UTC. So,
"utc_offset":-28800
corresponds to -28800/3600 = -8 hours from UTC.
There are a couple of suggestions that this doesn't get adjusted for daylight savings.
The timezone of each tweet is automatically converted to the local timezone. If you need UTC, you can use the .ToUniversalTime() method, for example:
myTweet.CreatedDate.ToUniversalTime();
Time zone is in the user settings under delivery options.
Unfortunately, I think It is impossible. Twitter does not store any information related to local timezone. I found that user.utc_offset are always null.

Resources