Jquery datepicker - missing 28. of january 2015 - jquery-ui

idk why but datepicker do not show me 28. of January 2015.
Any ideas why?
I am using jQuery UI - v1.11.2
Thanks

Related

Create a datetime using strings in rails

What I would like to do is to go from "2013", "December", "20" and to create 2013-12-20.
Does someone have an idea ? Thanks !
Rails provide nice converters in part of it's framework
2.1.2 :001 > "20 december 2013".to_date
=> Fri, 20 Dec 2013
For your required format you can use this bit for formatting:
strftime("The date is %y-%m-%d")
This can be called on any time object.
You can do this:
Date.new(2013, 12, 20)
You can read more about Date here
This is an extension to #Marc-Alexandre Bérubé 's answer to get your desired format:
"20 december 2013".to_date.strftime("%Y-%m-%d")
# => "2013-12-20"

Returning days/months since latest post

I have this in my controller:
model.LatestPosts = db.TPGForumPosts.Select(v => v).OrderByDescending(d =>
d.dateCreated).Take(5);
This gives me the 5 latest posts.
I am going to display them on my cshtml page.
Is there an easy way to convert the date to days/months since today?
A cold hard truth by jwilson posted 5 days ago
A cold hard fact by jwilson posted 3 months ago
One option would be to use some jQuery and the timeago plugin: http://timeago.yarp.com/
Your view would need to look something like this:
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.timeago.js" type="text/javascript"></script>
<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>
jQuery(document).ready(function() {
jQuery("abbr.timeago").timeago();
});
There are a couple of options for this. If you want to go client side then TimeAgo or Moment.js are good options. To do this in .Net you can use NodaTime which is a great date/time library for .NET.

how to enable time series data in flot chart?

Flot documentation says that it is based on javascript timestamp.
I have tried to convert my JSON to comply this standard, and my JSON looks like this
{"label":"Activation","data": [
["1382061194000","10"],["1382061195000","9"],["1382061196000","9"],
["1382061197000","20"],["1382061198000","6"],["1382061203000","16"],
["1382061204000","12"],["1382061205000","14"],["1382061206000","22"],
["1382061207000","20"],["1382061208000","10"],["1382061209000","19"],
["1382061210000","13"],["1382061211000","9"],["1382061212000","12"],
["1382061214000","12"],["1382061215000","17"],["1382061216000","6"],
["1382061217000","14"],["1382061218000","22"],["1382061219000","43"],
["1382061220000","34"],["1382061221000","27"],["1382061222000","31"],
["1382061223000","2"],["1382061224000","1"],["1382061225000","86"],
["1382061226000","82"],["1382061227000","4"],["1382061228000","7"],
["1382061229000","6"],["1382061230000","18"],["1382061231000","17"],
["1382061232000","15"],["1382061233000","3"],["1382061234000","14"],
["1382061235000","2"],["1382061236000","8"],["1382061237000","14"],
["1382061238000","9"],["1382061239000","5"]
]}
And i setup flot options like this
xaxis: {tickSize: 1,mode: "time", timeformat: "%H:%M:%S"}
The chart never up :(
Well actually the goal is simple, I just want to show a flot chart with 08:02:30 08:02:31 as the xaxis info. Thanks for any help.
Your problem is that you're passing in your dates as strings.
> new Date("1382061194000")
Invalid Date
> new Date(1382061194000)
Thu Oct 17 2013 21:53:14 GMT-0400 (EDT)
Try removing the quotes (around your data points too) and see what that does.

Parse a date in rails

I have a date (Which is actually parsed from a PDF) and it could be any of the following format:
MM/DD/YYYY
MM/DD/YY
M/D/YY
October 15, 2007
Oct 15, 2007
Is there any gem or function available in rails or ruby to parse my date?
Or I need to parse it using regex?
BTW I'm using ruby on rails 3.2.
You can try Date.parse(date_string).
You might also use Date#strptime if you need a specific format:
> Date.strptime("10/15/2013", "%m/%d/%Y")
=> Tue, 15 Oct 2013
For a general solution:
format_str = "%m/%d/" + (date_str =~ /\d{4}/ ? "%Y" : "%y")
date = Date.parse(date_str) rescue Date.strptime(date_str, format_str)
I find the chronic gem very easy to use for time parsing and it should work for you. i tried the examples you gave.
https://github.com/mojombo/chronic

Datepicker and TimePicker in a form, datepicker works fine but timePicker doesn't drop down in field

First of all, I'm a novice at this stuff so excuse my "ignorance."
I am creating a form in order for customers to schedule a test drive on a vehicle they are interested in purchasing. I have found jquery code which I've included in the head section as follows:
$(function() {
$( "#datepicker" ).datepicker({ autoSize: true });
$("#time1").timePicker();
// 09.00 AM - 03.30 PM, 15 minutes steps.
$("#time2").timePicker({
startTime: "09.00", // Using string. Can take string or Date object.
endTime: new Date(0, 0, 0, 15, 30, 0), // Using Date object.
show24Hours: false,
separator:'.',
step: 15
});
});
In the form, I have added the following:
<b>Pick a Date and Time</b><br>
<span class="auto-style7">Date: </span>
<input type="text" id="datepicker" name="testdrivedate" style="width: 91px" /><br>
<span class="auto-style7">Time: </span>
<input type="text" id="time2" name="testdrivetime" size="10" value="09.00 AM" style="width: 87px"/><br>
The datepicker works well, when the user clicks in the field, the calendar shows up just below the field and when a date is selected, the field is populated with the date selected.
However, the timepicker field does not work. 09:00 AM appears in the form, but when the user clicks in the field, no drop down appears in order to allow for selection of a different time.
Where have I gone wrong?
Thanks for any assistance.
Anna
Based on your comment above, I would guess your code is not executing because you have not included jquery.timePicker.js in your code. Download the file and include it like this:
<script src="path/to/your/js/file/jquery.timePicker.js"></script>
You don't need to include datePicker.js because datepicker is a plugin included with the jquery-ui library. (So really you do have datepicker included!)
Also, looking at your comment, you do not need to have a ; after declaring a <script> tag
Like this:
<script></script>
Not like this:
<script></script>;
EDIT
I found the issue, it appears the jquery.timepicker.js library is quite old (2009). It was developed with a much older jquery version. When I run jquery.timepicker.js with a newer version of jquery, I get this error in the console:
Uncaught TypeError: Cannot read property 'opera' of undefined on jquery.timePicker.js line 130
When I checked line 130 in jquery.timepicker.js, the error was complaining about $.browser being undefined. You are using jquery 1.9.1, and as of jquery 1.9 the jquery website states this about the $.browser object:
This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead.
See this page for more information on the jquery browser element: http://api.jquery.com/jQuery.browser/
It looks like you would have to try and use the jquery.migrate plugin if you want to get $.browser and jquery.timepicker.js to work. I'm not sure how difficult this will be as I've never used the jquery.migrate plugin before.
As another a solution, it looks like jquery 1.8.3 plays nicely with both jquery.timepicker.js and jquery-ui 1.10.3 (which is what you are also using). You can either use jquery 1.8.3 instead of 1.9.1:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
Or you should use the latest version of jquery, jquery-ui and a newer jquery timepicker plugin. On google search, the first entry for jquery timepicker is this one http://trentrichardson.com/examples/timepicker/ dated May 5th, 2013 which is quite recent. That might work better for you.
Good luck!

Resources