Date custom format Angular Js [duplicate] - ruby-on-rails

Is there any directive in Angular, I want to enable user when he write 2/3/67 in input for date date needs to be formatted like 02/03/1967 I tried few things on my own but they didn't work.

Just add a Angularjs formating, when displaying users input like so
{{yourdate.variable | date:'yyyy-MM-dd'}}
Se more at AnguarJS date function
EDIT
Here is working Plunker, with different type of dates. Enjoy

Related

Displaying a different date than is submitted rails datetime_field

I have several datetime_field in my application. By default, they are displaying the date as the rails format, as I dictated that for my bootstrap-datepicker:
format: 'YYYY-MM-DD HH:mm:ss'
The issue: I want the date on the views to display in a different format, say:
'MM-DD-YYYY HH:mm:ss'
I've been scratching my head for a while on this one. Every change I make to the view side, be it by Javascript, jQuery, rails methods, helpers, whatever - they all affect the submit data, which then becomes invalid, because Rails expects the first format.
I don't want to change the default date format - we have other aspects of the website that need the database in the normal rails format. I just want to change the display of the date in the datetime_field, without changing the submitted date.
My guess would be it was an option in the datetime_field, but I can't seem to find one:
<%= f.datetime_field(:end_date, {?????})%>
Any suggestions on how to accomplish this?

Formatting Orbeon Date input fields

I am trying to format an input field of the type xs:date in Orbeon.
I have tried using the xxf:format attribute, but the datepicker can not understand the date when it has been modified.
The idea now was to change the javascript of Orbeon to use the xxf:unformat attribute to interpret the date and transform it back to ISO format.
I've tried changing the data.js but for some reason none of the changes can be seen.
Am I changing the wrong file?
Edit
I figured out that the xforms.js has a function 'getCurrentValue' which is being as the changes I do there are visible. Now I just need to figure out who is the one that's calling the function.
Edit:
It is the Calendar who requests the value of the input when the user clicks on the symbol. This all happens at the client side, and the generated HTML does not have the format/unformat attributes. However I want to use their value. Can I make a request to Orbeon to get it? How?
In case you're using an xf:input bound to a node of type xs:date, you can control the formatting of the date field with the oxf.xforms.format.input.date property. A few formats are supported, and if you want to add more, the best would be to follow the pattern currently used for the currently supported formats.
E.g.
[M]/[D]/[Y]
[Y]-[M01]-[D01]

x-editable with meteor textarea no line breaks and date timezone issue

I'm currently trying to work in bootstrap x-editable to my meteor application. I'm using the atmosphere package for this: https://github.com/nate-strauser/meteor-x-editable-bootstrap. I'm having a couple of issue so far which are:
When I select a date using the date data-type I get a javascript date object back that is 4 hours behind what I actually picked(assuming this is because I'm in -4 timezone).
When I edit a textarea, the line breaks are saved to the database, but when bring up the editable to edit it the line breaks are striped.
It looks like this might be the intended behavior. Its hard to be sure without more information.
With the date, javascript stores date in unixtime. This is because its very easy to switch timezones and not worry about having javascript itself having to keep track of DST and the other complications of keeping time.
If you use new Date(<the javascript timestamp>); you should get the time in your timezone.
With the textarea it looks like some kind of text-encoding conversion is taking place. You should check to see what the character codes of those stripes are and convert them to newlines like \n. One scenario this could occur is if you're copy-pasting stuff with a different encoding into the textarea.

How do I get a date from a Rails app into a Sencha Touch 2 app without it being an invalid date?

Problem: Get a date inside of a JSONP response that looks like "2012-11-11T04:27:25Z" (which is the default date output from a Rails app) into a date field in a model instance in a Sencha Touch 2 app without it being an Invalid date.
Background: I have a Rails app that is generating JSONP, which I read into a Store in my Sencha Touch 2 app, and the date, as formatted by Rails comes into the Sencha Touch 2 app as an Invalid Date.
To reproduce: To reproduce the problem for this question and duplicate the error, use the Fiddle below. Note: I took the Rails server out of the picture by hard-wiring the data into a store with a date formatted the same way my Rails app has been outputting them. So, in other words, I have reproduced the entire problem locally in the Sencha Touch 2 app by mimicking what my Rails app does server-side.
Fiddle: http://www.senchafiddle.com/#7qQkb. To see the problem, run the Fiddle from a Webkit browser and view the JavaScript console inside the Webkit Developer Tools.
Symptom: What will happen is that the XTemplate that is created by the List component within the app executes code (inside {[]} brackets) to output a date for your inspection in the console. When you inspect the date that is outputted, you will see: __proto__: Invalid Date. The date will still show up just fine in the view, but because it is an invalid date, I cannot format the date or retrieve different parts of the date object.
My question is this: Is there something that I can do to my model or my store, or alternatively to my Rails app, to get the date into a model instance without it being an Invalid Date?
What you see is just the returned value of toString method in the Date prototype
Date.prototype.toString(); // "Invalid Date"
That´s why absolutly all the "dates" say exactly the samething. However, it doesn´t mean date are wrong! In extjs, if you want to format a date field in you model you should use:
{ name: 'timestamp', type: 'date', dateFormat: "Y-m-d H:i" }
But if you only want to format it to display it, you can use the format yo used, one of the named built-in format or just the sameone I used in the example: Y-m-d H:i
I have answered this question through some more research. The default way that Rails represents dates in a JSON / JSONP response is adequate for Sencha Touch 2. The __proto__ property of the date object will always represent as an Invalid Date, but you can still manipulate the date by using Ext.Date.format() in your XTemplate object as follows:
'<p>{[Ext.Date.format(values.timestamp, "F d, Y g:i A")]}</p>'
(where timestamp is the date you wish to format.)
The fact that it shows up as Invalid Date in the console is of no consequence.

Orbeon form builder: Using date fields with initial value "current-date()"

I am using date fields in Orbeon form builder that should be prefilled with the current date (see http://i42.tinypic.com/erdjrb.jpg). When choosing a date by hand in the form, the date format in resulting XML model is set to "2011-07-12". But when not changing the default value of current-date(), then I get "2011-07-12+02:00". Does anybody know why the date format is different when I prefill it with current-date()?
Thank you!
The XPath function fn:current-date() by definition returns the date together with explicit time zone information. I assume orbeon just passes the function call to the XPath engine (Saxon i think). A quick workaround would be to format the result of current-date() using format-date(), for example:
format-date(current-date(), '[Y]-[M01]-[D01]')
Since i don't use Form Builder, i can't tell in detail, but i assume setting the config options how to format xforms:input controls regarding date and time values applies for form builder, too.

Resources