Trying to use the actual 'day of the week' to show api data in react native - json

This is my first post here at StackOverflow.
I've tried to search the internet for a while now, but probably because i don't now what to search exactly I can't find the answer online.
I have done a react-native beginners tutorial on how to make an api call and list the results in a flatlist. Everything is working fine, but when I try to add another field that show's the opening hours of that particular day it only works when I hardcode it like this:
<Text style={styles.hours}
numberOfLines={1}>{item.day5}</Text>
This correctly shows the opening hours of Friday, provided by the api. What I would likt though, is to show the opening hours of the actual day of today.
I already managed to calculate the day number and show it in the console by:
let date = new Date();
let dow = date.getDay();
console.log( 'The day is ', dow );
This returns the correct day number. I'm sure it is probably something really simple but I still can't figure out how to use this day number to actually show the current day's opening hours.
Anyone here who can help me out?
Regards, Jelle

Related

Google Sheets Price Tracker for Amazon not functioning properly

Hi so i'm using a slightly edited version of a price tracker made by someone else. The purpose of this tracker is to track the price of certain items on Amazon and then display them without me having to check each price individually.
The problem however, is that the tracker is only returning the price of about 20 different items even though I have asked it to track more.
If anyone can take a look at the code and tell me what is causing it to "give up" after it has displayed about 20 items that would be amazing, I have had a look myself but i'm fairly new in the world of coding and I really don't know what the problem is.
If you can tell me how to fix the problem too that would be really helpful.
Main Script:
http://pastebin.com/4zfiZjnU
Table Script:
http://pastebin.com/sWSCM8w4
Row Script:
com/nWLzRNV5
Try changing function function trackPrices(). The line 'data = sheet.getRange(2, 2, 21, 3).getValues();' is only getting 20 rows (it skips the header row. Try changing 21 to your number of rows you have +1 and see if that works.

Google Analytics: Spreadsheet Add-on invalid value 'daysAgo'

I'm trying to do build an automatic report query with the Google Analytics spreadsheet add-on. I want to get a monthly report (start of month to end of month) about users, visits etc. According to the Google Analytics documentation, it's possible to set a startDate and endDate in the following format:
Values must match [0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo).
However i'm getting an error which looks like this:
Report failed
My settings looks like this:
Settings in Google Spreadsheet
Does anybody know what causes my error? This feature will be really handy.
Thanks in advance.
First you have to schedule your report every month and then you can use the function eomonth() to calculate start and end dates.
Start date -> = EOMONTH(TODAY(),-2) +1
End date -> = EOMONTH(TODAY(),-1)
Try running it on a different profile or a larger date range. I was able to get data using the exact query that you shared. You can also try the Google Analytics Query Explorerand see if that gives you works or it gives you more detailed error information.

How to retrieve more than a month of stock quotes using Yahoo finance api?

Basically I'm new to using Yahoo finance Api. I've tried YQL Console but I can seem to find what I needed. I have to get like 3 months worth of stock quoute data. I found this http://chartapi.finance.yahoo.com/instrument/1.0/GOOG/chartdata;type=quote;range=30d/json
This is exactly the sets of data that I needed but it only gives me a whole month of data. No matter how I change the range=30d to say range=90d it gives me the same result.
Sorry cant comment due to my low reputation.
what you need to do exactly is use the following arguments in the url
30days: 30d
90days/ 3months: 3m
180days/ 6 months: 6m
365days/1 year: 1y
so the link for 3 months will be
http://chartapi.finance.yahoo.com/instrument/1.0/GOOG/chartdata;type=quote;range=3m/json
Hope it helps. :)

How to create AllDay Event with Google Apps Script that span multiple days and show as a single bar

I have a script that takes event information for google sheet and adds them into a specified google calendar. So far everything works fine except when I try to create an all day event that spans multiple days. The scenario that I am fighting with is for vacation. If I create the event manually, I can choose "All day" and set a start and end date of two different days. Note, "Repeat..." is not used. Visually the event spans the days specified. This is what I want to duplicate with my script.
As far as I can tell, the API only provides:
calendar.createEvent(title, startTime, endTime)
which creates a non-all day event that does span days, but it shows the start time which is not what I want. The event is truly and all day event.
calendar.createAllDayEvent(title, date)
which creates and all day event for only one day.
What seems to be missing is
calendar.createAllDayEvent(title, startDate, endDate)
which is what is discussed here: https://code.google.com/p/google-apps-script-issues/issues/detail?id=952, but there isn't any significant movement on the issue.
A possible work around is discussed here: How to create two days AllDay Event with Google Apps Script?. The problem is creates what looks like multiple single all day events. I want the multi day to show up as spanning multiple days.
Has anyone found any other work around?
You can use createEventFromDescription(), it works perfectly for "n" full days.
var start = Utilities.formatDate(new Date(date_from), "GMT"-0500, "MM-dd-yyyy");
var end = Utilities.formatDate(new Date(date_to), "GMT"-0500, "MM-dd-yyyy");
var vacationCalendar = CalendarApp.getCalendarById(CALENDAR_ID);
vacationCalendar.createEventFromDescription(title+" "+start+"-"+end);
Edy's suggestion of createEventFromDescription() is nice and clean, +1.
With that being said, if you need more fine-grained control over the event and have a lot of metadata you're trying to set (such as location, description, attendees, etc), I would recommend using the new version of the Google Cal API aka "Advanced Calendar Service", which natively supports multiple-day all-day events.
Basically looks like this:
// end dates are exclusive, so this creates a 2-day event
// starting on the 9th and ending on the 10th
var event = {
summary: 'My Event',
start: {
date: '2015-04-09' // unfortunate it doesn't seem to accept JS Date() objects :(
},
end: {
date: '2015-04-11'
}
};
event = Calendar.Events.insert(event, calId);
For what it's worth, "use this new API" is also the answer given by a google dev on the issue ticket mentioned in the original description of this StackOverflow post.

calendarApp createEvent added event on wrong day

Here is my code:
function calEvent(){
var arrivalDate = "06/10/2013";
var departureDate = "06/18/2013";
var start = new Date(arrivalDate);
var end = new Date(departureDate);
var cal = CalendarApp.getCalendarById('id487g3esn088a00omqa99ugv0#group.calendar.google.com');
cal.createEvent('Apollo 11 Landing',start,end);
}
When I run this it will create the event in the correct calendar however it will only be from June 10 thru June 17. I need the event to cover June 10 - June 18.
I have checked the Timezone setting and the spreadsheet, script and calendar are all on the same time zone (Mountain Time GMT-7)
How can I get this seemingly simple code to set the event on the correct dates? I've tried several date formatting (utilities.formatDate) but can't seem to get the correct format.
Thanks in advance.
How to use timeZone of calendar to set timeZone for date object
I posed the above question a couple a weeks ago, and came up with a working solution. Not sure if it is the best or not, but you can look over and see if it helps. In working on a solution for my question I noticed several things. The script definitely uses the script timezone to create a date object. But when it post to a calendar it adjust the date to executors default calendar timezone not the timezone of the calendar you're writing too. So if a user's default calendar timezone is different from the calendar being written to you will get all kind of crazy time's
So the function gasTimezoneOffset() that is listed in the above question was my solution for this.
Hope this helps.