yahoo weather API YQL query update frequency - ios

select * from weather.forecast where woeid in (SELECT woeid FROM geo.placefinder WHERE text="30.7063633,76.7047791" and gflags="R")
I am using the above YQL to fetch the weather conditions for some lat, lng to show in my iOS app. The response has "pubDate":
"pubDate": "Fri, 29 May 2015 8:30 am IST",
"condition": {
"code": "28",
"date": "Fri, 29 May 2015 8:30 am IST",
"temp": "89",
"text": "Mostly Cloudy"
My concern is, will this "pubDate" ever change? I mean at 8:30 am the weather is mostly cloudy may be at 12 noon it won't be. If i access this YQL at 12 Noon the response will be same ??
Also, I have no idea about the "and gflags="R"" part of the query..

As per Yahoo developer docs here.
pubDate The date and time this forecast was posted, in the date
format defined by RFC822 Section 5, for example Mon, 25 Sep 17:25:18
-0700.
lastBuildDate The last time the feed was updated. The format is in
the date format defined by RFC822 Section 5, for example Mon, 25 Sep
17:25:18 -0700.
So, until and unless the backend gets an update of "temperature change" for a particular location, the API will not reflect any change. So that's why "lastBuildDate" is also comes in the json, which specifies when the temperature feed was last updated. So you can't do anything manually to get the temperature of a particular location for current time,

If you try to call this API in different moments during the same day you will see that lastBuildDate is the same date and time of your call.
The problem here is that the date in the condition doesn't change, and after some time the condition itself becomes obsolete, as you can easily verify using yahoo meteo app.

Related

What means "Invalid date specified" on querying of Google Analytics API

I query Google Analytics API from outta Google Sheets.
My endDate I define in B2 as =today(), my startDate I define in B3 as =B2-30.
B2 and B3 cells I formatted manually as date in yyyy-mm-dd format.
On running a query I get an error:
{ "error": { "code": 400, "message": "Invalid Date specified: Wed Oct 27 2021 00:00:00 GMT+0200 (CEST)", "status": "INVALID_ARGUMENT" } }
What is wrong with my date input?
I have one guess, my dates from B2 and B3 are transmitted to API instead of format mm/dd/yyyy in the format Wed Oct 27 2021 00:00:00 GMT+0200 (CEST). If my guess is correct, how can I turn dates into the right format?
To use dates coming from formula like =today() and derivative calculations it doesn't help to re-format values as dates manually, using GSheets formatting function, as I tried it before.
The way I worked it successfully out, is to explicitly make a text from values while formatting it to the needs, like it explained in the according documentation:
=TEXT(TODAY(),"yyyy-mm-dd") and =TEXT(B2-30,"yyyy-mm-dd")

How to include a time zone in the way formatted slack dates are displayed?

The ability to use date formatting in the Slack API to display a date/time in the local timezone of the person seeing the message is great, but I'd like people to know that the date/time is in their local timezone.
Using <!date^1392734382^{date_short_pretty} {time}|2014-02-18 6:39 AM PST> will display as "Posted Feb 18, 2014 6:39 AM" if the receiver is in California, and "Posted Feb 18, 2014 8:39 AM" if the receiver is in Chicago (see here in Block Kit Builder) but there is no indication to the receivers that the date/time is in their own timezone.
Is there any way to include the receiver's time zone as part of the token string?
This is not a feature that is provided by the API. The only solution I can think of is to add some info text like "(local time)" to the datetime output in your message.

Google Spread Sheet Script. Working with Dates

I am reading list of Google Sheet cells containing DateTime, using Google Apps Script.
The values in the cells are:
A1: Jul 26 13:00
A2: Jul 27 0:00
var dateValues = SpreadsheetApp.getActiveSheet().getRange("A1:A2").getValues();
However, values read are 1 hour behind. This is what I see in the debugger:
dateValues[0] = Wed Jul 26 2017 12:00:00 GMT+0200 (EET)
dateValues[1] = Wed Jul 26 2017 23:00:00 GMT+0200 (EET)
I guess this is a time zone issue, but I don't really understand the concept.
My time zone is currently (due to DTS) GMT + 3. Indeed, outside the DTS period it is GMT +2. The spread sheet time zone is Jerusalem GMT+2.
EET - don't underrated why it is being used.
Basically, I would expect to get in code the values with in the sheet.
What is the concept?
there are two ways to solved this
Use getDisplayValues() rather than getValues(). This will force to do some conversions, as getDisplayValues() returns strings not dates
make you script editor time zone match the sheet tz.
In my case the sheet was (GMT+2 Jerusalem), but the script editor was different (GMT+2 Moscow) for some reason.
Setting the script editor TZ, solved the problem.

Google timezone API - timestamp parameter

In my client application I have the Latitude & longitude information from skyhook API based on its I.P.
Now based on the latitude and longitude information I need to find out the timezone information of the client. But in the google timezone API documentation https://developers.google.com/maps/documentation/timezone/ I see that timestamp is a mandatory field. In which case what should I need to do.
Also can you kindly help me understand what does the timestamp corresponds to? For e.g :- If my Application server is in U.S.A (say PST timezone) and it makes the google API call passing the server timestamp.
If user logs into client application from India passing lat / long information, to the app server to get the timezone information what will the API provide as dstOffset and rawOffset? i.e If I add the server timestamp with dstOffset and rawOffset will I be getting the client machine timezone information?
I've been scratching my head on Google's Timezone API for a few minutes, specifically on the timestamp parameter. Maybe this will lay out the need:
In San Diego, we (now, in August) have a GMT offset of -8 because of daylight savings time. However, in November we'll have a GMT offset of -7.
So which gmt offset should Google return? -7 or -8? They're both valid, but it depends on what day you take the measurement.
Enter the Timestamp argument. Running the service now, and using a timestamp value of August 2015, I get this response:
{
"dstOffset" : 3600,
"rawOffset" : -28800,
"status" : "OK",
"timeZoneId" : "America/Los_Angeles",
"timeZoneName" : "Pacific Daylight Time"
}
But if I bump the timestamp to November 2015 (once San Diego is out of daylight savings, I end up with this):
{
"dstOffset" : 0,
"rawOffset" : -28800,
"status" : "OK",
"timeZoneId" : "America/Los_Angeles",
"timeZoneName" : "Pacific Standard Time"
}
In both cases the rawOffset is the same, but the DST changed because of the timestamp I provided. If you just want to know the raw timezone, the timestamp doesn't matter.
But if you want an application to reliably do something at 8:00am in San Diego in August and 8:00am in November in San Diego, you'll need to engage the timestamp.
Putting it another way, what's the value of knowing that San Diego is normally -7 hours offset from GMT. If you're working with timezones, you're likely trying to ensure that your UTC time is matched up with what a real person in that location is experiencing. As such, the DST offset is critical.
The documentation link you provided clearly states that the timestamp should be in UTC and that it is used to show the correct DST offset value. It will also control if the timeZoneName field is shown with "Standard" or "Daylight" in the name.
If you don't care about that and just want the timeZoneId field, then it doesn't matter what value you pass.
Try this
DateDiff("s", "1/1/1970", DateTime.Now)

Rails: how to create Time object in specific time zone

My app is working in "Moscow" (+04:00) timezone. But sometimes I need to create time object by only local time (for example "01 may 2012 13:45") and name of ActiveSupport::TimeZone object (for example "Berlin": +02:00 in Summer Time and +01:00 otherwise).
For example if I get "01 may 2012 13:45" and "Berlin" as input I want to yield "2012-05-01 13:45:00 +0200" or "2012-05-01 11:45:00 +0000". I create following function:
def from_local_datetime(local_datetime, time_zone)
offset = Time.now.in_time_zone(time_zone).formatted_offset
datetime = case local_datetime
when String
DateTime.parse(local_datetime)
else
DateTime.new(local_datetime)
end.change(:offset => offset)
return datetime
end
And at the first look it works as I expected. But is it a best practice for this kind of task? May be in some situation It works with errors. I'm not definitely sure.
I would be greatful to any comments.
UPD: I think bug may occur about time when DST changing the time. For example 26 march 2011 was GMT+1 in Berlin time zone and Time.now.in_time_zone("Berlin").formatted_offset returns "GMT+1", but it would be GMT+2 in 27 march 2011. So if I call from_local_datetime("28 march 2011", "Berlin") before 27 march it returns 28 march 2011 00:00:00 +0100, but If I call it after changing the time my function returns 28 march 2011 00:00:00 +0200 :(
Your conversion method is the right approach.
With web sites, you should make sure times are stored as UTC in the database. If you can get the UTC value out of the database, instead of the local time (or maybe you can set your web server's time zone to UTC) it won't have to convert the time from UTC to local time, when you are going to then convert it to the user's timezone anyway.
And, of course, you will have to store the user's time zone preference.
TZInfo::Timezone.get('Europe/London')
Find the time zone
http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html

Resources