DatePickerIOS, in april and may show wrong date for 1976. React native - react-native

When picking a date in april and may for 1976, always show 1 day before on calander. However, in other months it comes true.
How we can handle this issue ?

Related

How can I display time like 30 seconds ago or 2 hour ago and update up to days in react native

Hi there I am developing a social application I want to display passed time i.e when the post was created like Facebook for examples created 30 seconds ago or created 2 hour ago and up to days in react-native
You can use momentjs for the same
Example can be :
moment([2022, 05, 22]).fromNow(); // 2 days ago
Or you can pass any date object and use fromNow()
You can get following output based on criteria
In my opinion better library for updating date is dayjs or date-fns. Both libraries are light weight. Specially if you are creating social app where I assume you would like to render a lot of dates.
https://date-fns.org/
https://day.js.org/
In dayjs what are you looking for is: dayjs(someDate).fromNow() from is output like this: 3 minutes ago
Thanks for your help friends I have found my answer. It was a single line and easy using 'moment' library here is how I got it:
let createdAt = moment(moment.now()).fromNow();
for display
<Text> Createdat: {createdAt} </Text>

later.js every nth weekday of every month

I am using later.js (meteor package, voidale:later-js-tz#1.1.9) to schedule events, using the later.parse.text() parser.
I can schedule weekly events on a given weekday with no problem, with strings like 'at 11:00 on Monday'.
But I get parse errors trying things like 'at 11:00 on every second Monday of every month'.
Q: Is there a way to do this in later.js, or if not, is there a javascript library available that does support this?
Thanks.
I found moment-recur, which supports this nth-weekday of a month in its API, but doesn't have a text parser.
I then used PEGjs to build a text parser which outputs the necessary parameters, which I use in a straightforward way to call the moment-recur API.

Eventfinder API: start_date parameter doesn't work

I am trying to get results from the Eventfinder API. It's a REST based service.
I want to get events from tomorrow.
But instead I will always get events from today (probably because default time is now).
Let's assume we have Friday the 2014-03-28 and I want events of Saturday the 2014-03-29.
When I request this url:
http://api.eventfinder.co.nz/v2/events.xml?rows=1&start_date=2014-03-29 I am getting events of the 2014-03-28.
For me it's not clear how to set the time, after I read the documentation on Eventfinder.co.nz
Now I have found a solution by myself.
It's important setting the end_date parameter too. If the end_date is not set, the event must happen at the current date AND a the date where the start_date is set.
This is an example usage, getting events of Saturday the 2014-03-29.
http://api.eventfinder.co.nz/v2/events.xml?rows=1&start_date=2014-03-29&end_date=2014-03-30

Capybara and jQuery datepicker: Capybara thinks certain dates on the calendar are clickable (valid dates) when they aren't

I have a test I am doing where I am testing the available dates that my website shows for the datepicker. The datepicker is supposed to make the next X business days available, and ignore weekends and holidays.
I was testing two scenarios, 1 that looks at pickup dates for people who place orders (on July 1st) and choose to pick up, where the next 5 business days(July 2nd, 3rd, 5th, 8th, and 9th) are available. I brute force tested it with the following rspec/capybara code and it passes no problem:
find("#datepicker_").click
find(".ui-datepicker-group-first").should_not have_link("1")
find(".ui-datepicker-group-first").should have_link("2")
find(".ui-datepicker-group-first").should have_link("3")
find(".ui-datepicker-group-first").should_not have_link("4")
find(".ui-datepicker-group-first").should have_link("5")
find(".ui-datepicker-group-first").should_not have_link("6")
find(".ui-datepicker-group-first").should_not have_link("7")
find(".ui-datepicker-group-first").should have_link("8")
find(".ui-datepicker-group-first").should have_link("9")
find(".ui-datepicker-group-first").should_not have_link("10")
The next test deals with shipping the item instead of picking up, so with a 5 day shipping time, the available dates should be the 3rd, 5th, 8th, 9th, 10th, 11th, 12th, 15th, and 16th. However, my test (same as above, but looking at range between 2nd-17th) is failing, even though the datepicker shows only the correct dates that I am expecting as available. For some reason, it's saying that the 2nd and 6th have links (i.e. selectable dates) when they clearly do not. An example of the error cna be seen below:
Failures:
1) cart functionality should make the right delivery dates available in the cart
Failure/Error: find(".ui-datepicker-group-first").should_not have_link("2")
expected #has_link?("2") to return false, got true
# ./cart_functionality_spec.rb:100:in `block (2 levels) in <top (required)>
I took a screenshot of what the browser looked like during the test when I froze the test with Pry right before it did the check with rpsec. The screenshot can be seen below
What's weird is that the July 4th, other weekends such as July 7th, and July 17th don't trigger this error. If I comment out the test for the 2nd and the 6th, the test passes. Does anyone know why this is happening?
I'm working with:
Capybara 2.1,
Rspec-rails 2.14.0
I found the issue. Since the 2nd wasnt a link and the 12th was a link, when i used the code
find(".ui-datepicker-group-first").should_not have_link("2")
It detected a link for the date "12". This same scenario happened for the 6th and 16th. I changed the test to:
find(".ui-datepicker-group-first").should_not have_link(/^(2)$/)
and that fixed the problem.

Selecting a datetime range in YII input form

Here is the problem.
I have to create a submission form on my Yii-based website. The form requires to enter a datetime range.For that I am using "jui datetimepicker" third-party Yii extension.
http://www.yiiframework.com/extension/datetimepicker/
I use two date fields with this extension pertaining to start and end time respectively. So, what I want to achieve is be able to restrict the start datetime only to time in the future (neither past dates nor time should be selected) and the end time itself should be restricted to the maximum of three hours following the start time.
EXAMPLE: a user wants to schedule an event. They choose a date and time, which are of course in the future. Let's say they choose March 15, 13 O'clock as the start time in the start time field. Once they are done and move to the next field ("end time"), the respective datetimepicker restricts the range of time from March 15, 13:00 to March 15, 16:00.
Hence the second datetimepicker should be dynamically updated depending on the input of the first one.
It's possible o specify date range in the datetimepicker starting from the current date, but there is nothing like that for the time selection, so a user still can select time which has already passed.
It's not that I want to solve this problem with this extention, if anybody has any suggestions about YII solutions allowing to specify a datetime range in the most clean and effective way - it would be much appreciated.
You should use the edaterangepicker extension instead.
Given the API for the jquery timepicker addon. you should add the following to your widget call (along side 'model','attribute', etc)
'options'=>array(
'minDateTime'=>'<start dateTime here>',
'onSelect'=>'<JS function to run>'
)
The function you run on the "onSelect" event should dynamically set the minDateTime for the second dateTime input field, for ex:
function (selectedDateTime){
<EndDatePickerElement>.datetimepicker('option', 'minDateTime', <start dateTime here using selectedDateTime> );
}
There are more examples on the link provided earlier if you need to make it even more precise (like say if you wanted the starting date to be pushed back by the amount of time the user was on the page rather than it being set when the page was loaded. etc...)