HTML5 Input - Date (including Day) for iOS - ios

I am trying to use an HTML5 input in MobileSafari to get date. When I use 'date', it shows three reels, Month, Day (#), Year:
Jan | 4th | 1948
When I select 'datetime', it shows 4 reels for date and time:
Wed Mar 6 | 3 | 05 | PM
Is there a way to make it just show the 'Wed Mar 6' from the 'datetime' and the year in the native selector? I'd like users to be able to see the day when they make the date selection instead of having to count how many days until Friday. I don't need the time selection, But I want the date formatting from that input type.

It's browser-implementation dependant sorry. You'd have to make your own browser and make them use that. As far as I'm aware HTML5 isn't actually 100% out yet; w3c are still tweaking it and browsers can't agree on how to render the new elements.
If it's absolutely essential you may have to consider using a flash or java plugin object.

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

Date format bug when date is in Portuguese?

I'm seeing some odd behavior in our application coming from a user working in what I believe to be Portuguese.
I realized that Rails seems to be mis-interpreting the dates she is submitting. Here's some examples:
Date.parse("ter, 30 abr 2013 07:00:00 GMT-07:00")
=> Thu, 30 May 2013
Date.parse("dom, 5 mai 2013 07:00:00 GMT-07:00 -07:00")
ArgumentError: invalid date
Is there something extra I need to do correctly identify dates being submitted in other languages?
Date are parsed with Ruby Date class with the following documentation
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-c-parse
I'm not sure it's a great idea to allow your users to type in the full date by themselves - they can mistype or assume different format. I suggest to use datepicker that with localized presentation based on the users location? One of the the many date pickers that allow this is http://docs.jquery.com/UI/Datepicker/Localization

It is possible to change or disable Date validator in jira

I change calendar javascript to Hijri, But another problem comes up. It seems that a class (DueDateValidator.class) try to validate input date, while the number of days in month is different to georgian calendar. for example we have 31 days in second month of year but in georgian (february) it is 28 or 29.
I don't think there is an out-of-the-box option to cancel Jira's date validation. You could overwrite Jira's date validation, but I think it will be easier to use a Free Text Field custom field that will hold the date as a string. Then, add to the field js code that will hide this field and copy it's date to the date field.
To keep the right order when searching for issues, you can either use date mapping to keep the georgian calendar up to date, or store the dates in a sortable way (for example YYYY/MM/DD/HH/MM - 201302161334) and order the results according to this field.
UPDATE
Simple example for Jira version 5.2.6, this will copy the text from field id customfield_10001 to the created field:
AJS.$("#create-date").text(AJS.$("#customfield_10001-val").text().trim())
To search easily keep another text field and save the date in the following format :
year month day hour minute
All in digits. for example, today's Gregorian date would be:
2013 02 267 10 26
than, when searching for issues, for example to find issues created after today's date:
custom_filed > "2013 02 267 10 26"
that sorting will work since it will sort issues first by year, than month, day, hour, minute.
I stored date in text field by creating new custom field in system-customfieldtypes-plugin.xml filed but In search it only accept exact text not > or <
custom_filed ~ "2013 02 267 10 26" It is acceptable but
custom_filed > "2013 02 267 10 26" shows jQL error.

Rails UI date navigation control generation (ActiveRecord logic)

I have an app where users can view sporting events for today's date or a given date (if the user manually enters it in the URL). A user can navigate sporting events by date with a UI control, which crudely looks like this:
Tue Nov. 27 | Wed Nov. 28 | Thu Nov. 29
(The dates are links except the current active one in the middle.)
This date nav control works great for sporting events that occur nearly every day. The user is never staring at a blank page of events. However, for sporting events such as the NFL, events only occur on Monday, Thursday, Sunday (sometimes Saturday) and it becomes cumbersome for the user to use the date nav UI control.
What I'd like to do is to change the logic behind the creation of the date nav UI links to include only those dates that have events. The logic would be something like:
Given today's date or a date supplied by the user, return the nearest date which has events (current_date)
Given a current_date, find the nearest previous date which has events (previous_date)
Given a current_date, find the nearest next date which has events (next_date)
So, in the case of the NFL, the date nav UI control might look like, assuming today's date is Nov 27:
Mon Nov. 25 | Thu Nov. 29 | Sun Dec. 2
The way in which to tell if there are any events for a given date is by start_time field in the DB.
I don't like to post a question without some code, but I'm looking for some guidance as to how I should approach this without having to hit the DB a ton of times.
NOTE #1: When you click on a date for a sport, it returns all the events for that date. The date nav is not used for viewing individual events.
Create a scope method in your model that grabs the next two start dates for the given sport, and the most recent start date. Limit it to return only three records.
Use this scope in your controller to fetch only those three game objects. With those three game objects in the controller, pass them to a view partial as an instance variable (e.g. render #games), and in the partial, write the generic link code <%= link_to "#{#games.start_time}", your_path(#game) %>. Rails will automatically iterate this partial for the number of objects in the collection (the three games).
Source: http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials

How to convert MS excel date from float to date format in Ruby?

Trying to parse and XLSX file using roo gem in a ruby script.
In excel dates are stored as floats or integers in the format DDDDD.ttttt, counting from 1900-01-00 (00 no 01). So in order to convert a date such as 40396 - you would take 1900-01-00 + 40396 and you should get 2010-10-15, but I'm getting 2010-08-08.
I'm using active_support/time to do calculation like so:
Time.new("1900-01-01") + 40396.days
Am I doing my calculation wrong or is there a bug in active support?
I'm running ruby 1.9.3-mri on Windows 7 + latest active_support gem (3.2.1)
EDIT
I was looking at the older file in Excel with the wrong data - my script / console were pulling the right data - hence my confusion - I was doing everything right, except for using the right file!!!! Damn the all-nighters!
Thanks to everyone replying, I will keep the question here in case somebody needs info on how to convert dates from excel using ruby.
Also for anyone else running into this - spreadsheet gem DOES NOT support reading XLSX files at this point (v 0.7.1) properly - so I'm using roo for reading, and axlsx for writing.
You have an off-by-one error in your day numbering - due to a bug in Lotus 1-2-3 that Excel and other spreadsheet programs have carefully maintained compatibility with for 30+ years.
Originally, day 1 was intended to be January 1, 1900 (which would, as you stated, make day 0 equal to December 31, 1899). But Lotus incorrectly considered 1900 to be a leap year, so if you use the Lotus numbers for the present and count backwards, correctly making 1900 a common year, the day numbers for everything before March 1st, 1900, are one too high. Day 1 becomes December 31st, 1899, and day 0 shifts back to the 30th. So the epoch for date arithmetic in Lotus-based spreadsheets is really Saturday, December 30th, 1899. (Modern Excel and some other spreadsheets extend the Lotus bug-compatibility far enough to show February 1900 actually having a 29th day, so they will label day 0 "December 31st" while agreeing that it was a Saturday! But other Lotus-based spreadsheets don't do that, and Ruby certainly doesn't either.)
Even allowing for this error, however, your stated example is incorrect: Lotus day number 40,396 is August 6th, 2010, not October 15th. I have confirmed this correspondence in Excel, LibreOffice, and Google sheets, all of which agree. You must have crossed examples somewhere.
Here's one way to do the conversion:
Time.utc(1899,12,30) + 40396.days #=> 2010-08-06 00:00:00 UTC
Alternatively, you could take advantage of another known correspondence. Time zero for Ruby (and POSIX systems in general) is the moment January 1, 1970, at midnight GMT. January 1, 1970 is Lotus day 25,569. As long as you remember to do your calculations in UTC, you can also do this:
Time.at( (40396 - 25569).days ).utc # => 2010-08-06 00:00:00 UTC
In either case, you probably want to declare a symbolic constant for the epoch date (either the Time object representing 1899-12-30 or the POSIX "day 0" value 25,569).
You can replace those calls to .days with multiplication by 86400 (seconds per day) if you don't need active_support/core_ext/integer/time for anything else, and don't want to load it just for this.
"Excel stores dates and times as a number representing the number of days since 1900-Jan-0, plus a fractional portion of a 24 hour day: ddddd.tttttt . This is called a serial date, or serial date-time." (http://www.cpearson.com/excel/datetime.htm)
If your column contains a date time, rather then just a date, the following code is useful:
dt = DateTime.new(1899, 12, 30) + excel_value.to_f
Also keep in mind that there are 2 modes of dates in an excel worksheet, 1900 based and 1904 based, which typically is enabled by default for spreadsheets created on the mac. If you consistently find your dates off by 4 years, you should use a different base date:
dt = DateTime.new(1904, 1, 1) + excel_value.to_f
You can enable/disable 1904 date mode for any spreadsheet, but the dates will then appear off by 4 years in the spreadsheet if you change the setting after adding data. In general you should always use 1900 date mode since most excel users in the wild are windows based.
Note: A gotcha with this method is that rounding might occur +/- 1 second. For me the dates I import are "close enough" but just something to keep in mind. A better solution might use rounding on fractional seconds to solve this issue.
You're doing your calculation wrong. How do you arrive at the expected result of 2010-10-15?
In Excel, 40396 is 2010-08-06 (not using the 1904 calendar, of course). To demonstrate that, type 40396 into an Excel cell and set the format to yyyy-mm-dd.
Alternatively:
40396 / 365.2422 = 110.6 (years -- 1900 + 110 = 2010)
0.6 * 12 = 7.2 (months -- January = 1; 1 + 7 = 8; 8 = August)
0.2 * 30 = 6 (days)
Excel's calendar incorrectly includes 1900-02-29; that accounts for one day's difference between your 2010-08-08 result; I'm not sure about the reason for the second day of difference.

Resources