Results for query include and probably stop at july 2 2019 no matter how far back I try to go - reddit

https://api.pushshift.io/reddit/search/submission/?subreddit=celebs&limit=1000&sort=desc&before=1451606400000
Trying to get posts before January 1, 2016 12:00:00 AM. But the last result is from Tuesday, July 2, 2019 11:57:17 AM. Is this an issue with pushift or reddit? Thanks in advance

Related

Filter dates December text format D Google Sheets

I have a column of dates that I want to convert to the following format below:
Oct 1,5,10,12,18,19,26,27,28,29,30
Nov 2,3,4,9,17,18
Dec 3,22,23,24,25,26,27,28,29,30,31,30,30,30,30,30,30,30,30,30
Jan 1,2,3,4,5,6,16,18,19,26
Feb 2,9
Mar 2,8,9,10,23
Apr 13,19,20,21,22,27
I'm using e.g.
=join(",",(filter(text($H$38:$H$204,"d"),month($H$38:$H$204)=10)))
where $H$38:$H$204 refers to the dates to produce the days for October and other months which all work fine with the exception of December (12) which produces repetitive 30 at the end.
It's bizarre behaviour and I can't work it out.
ok got it thanks.
if the array has blank cells at the end it seems to produce this behaviour.
Use:
=join(",",(filter(text($H$38:$H$204,"d"),$H$38:$H$204<>"",month($H$38:$H$204)=12))) to filter out blank cells also.
Still bizarre it seems to happen for only one month.
Regards

Traverse through a certain month in Date with just a given integer

Would it be possible to go to a certain month of the year with just a given integer. For example
date = Date.today
=> Wed, 30 Dec 2015
What if I want to go back to a certain month based on that date and I am just given a number let's say 7 which is July in the Date::MONTHNAMES so would it be possible to do something like
date = Date.today
=> Wed, 30 Dec 2015
date.go_to_month_of(7) # which will bring me back to July 30, 2015
Okay I found it. It's:
date = Date.today
date.change(:month => x)
Hope this helps you!

Rails last day of last week bug?

I'm trying to get the last day of last week.
Today is:
d = Date.today
=> Sun, 22 Nov 2015
d.at_end_of_week
=> Sun, 22 Nov 2015
d.at_end_of_week.last_week
=> Mon, 09 Nov 2015
The last command should return Mon, 15 Nov 2015, no?
This also returns the same FYI:
Date.today.at_end_of_week.last_week
=> Mon, 09 Nov 2015
What am I missing here?
What you are seeing is correct. Note that last_week is an alias of prev_week which takes an optional parameter that defaults to Date.begining_of_week (:monday)
Resulting in trying to find the date in the previous week but from the past monday.
If instead you call Date.today.at_end_of_week.last_week :sunday. For what you try to accomplish you need a way to replace :sunday with something based on today's date. Maybe this but I haven't tried it.
Try:
Date.today.last_week.at_end_of_week

Get list of weeks that start on a Friday

I want to count the number of the weeks, starting from Friday.
For more explanation: usually the counting starts on Sunday or Monday, but in this case, I want to make it start on Friday.
Some examples:
2nd Jan 2015 (Fri) ~ 8th Jan 2015 (Thu) : 1st week of 2015
...
25th Dec 2015 (Fri) ~ 31st Dec 2015 (Thu) : 52nd week of 2015
1st Jan 2016 (Fri) ~ 7th Jan 2016 (Thu) : 1st week of 2016
...
30th Dec 2016 (Fri) ~ 5th Jan 2017 (Thu) : 53rd week of 2016
6th Jan 2017 (Fri) ~ 12th Jan 2017 (Thu) : 1st week of 2017
What I need to do is
1) to get the week number from the date
ex.
input: Fri, 02 Jan 2015
output: 1
input: Sun, 27 Dec 2015
output: 52
2) to get the date range for the given week number.
I found that .strftime("%V") does almost this, but it counts weeks by every Monday.
Does anyone know nice solution to this?
Here you go:
my_array = Array.new
(Date.today..Date.today.next_year).each do |date|
if date.wday == 5
end_week = date + 6.days
my_array << "#{date.day.ordinalize} #{date.strftime('%b')} #{date.strftime('%Y')} (#{date.strftime('%a')}) ~ #{end_week.day.ordinalize} #{end_week.strftime('%b')} #{end_week.strftime('%Y')} (#{end_week.strftime('%a')}) : #{date.strftime('%U')} week of #{date.strftime('%Y')}"
end
end
# sample output of first element of array
# 30th Oct 2015 (Fri) ~ 5th Nov 2015 (Thu) : 43 week of 2015
Note: You can set any range. here I have set from Today to next year
%U - Week number of the current year, starting with the first Sunday
as the first day of the first week (00..53)
%W - Week number of the current year, starting with the first Monday
as the firstday of the first week (00..53)
for more info: http://apidock.com/rails/ActiveSupport/TimeWithZone/strftime
You can do the variety of operation on the dates here...
DateAndTime
In your case, the below will work for you.
all_week(start_day = Date.beginning_of_week)

Should the beginning_of_week return the first of the month if not the beginning of the week?

I'm trying to set some date variables for reporting, so I was experimenting with date calculations.
yesterday = DateTime.yesterday()
which is July 10, 2015
yesterday.beginning_of_week
returned July 5, 2015 which is last Sunday.
(yesterday.beginning_of_week - 1.days).beginning_of_week
returned July 1, 2015 which is the prior Wednesday. This seems wrong.
(yesterday.beginning_of_week - 5.days).beginning_of_week
finally returned June 28, 2015. Which is correct.
Should the first of the month automatically be the beginning of the week for some reason unknown to me? Thanks...
EDIT -- MORE INFORMATION
Date.beginning_of_week
returns :monday
Date.new(2015, 7, 2).at_beginning_of_week
returns June 29, 2015, which is really expected for Monday.
I had the week_of_month gem installed and it was giving me bad results. I finally saw this in the backtrace. Thanks #DaveNewton for your help because I wouldn't have looked for that if you hadn't said you weren't seeing those results.

Resources