Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking with dates in breeze
    primarykey
    data
    text
    <p>I'm having some trouble working with dates.</p> <p>I have an object with a date field:</p> <p>public DateTime FechaInicio{get; set;}</p> <p>This definition generates the following field in the database:</p> <p>FechaInicio datetime not null</p> <p>Making the request to the web service I get the date ( in the JSON ) in the following format:</p> <p>"FechaInicio": "1982-12-02T00: 00:00"</p> <p>And calling FechaInicio() on tne entity returns a javascript Date object.</p> <p>Creating a new entity I get the following value:</p> <pre><code>createPalanca var = function () { MetadataStore var = manager.metadataStore; metadataStore.getEntityType palancaType = var ("Toggle"); palancaType.createEntity newPalanca = var (); manager.addEntity (newPalanca); //Here: newPalanca.FechaInicio () has the value in this format: 1355313343214 //Expected Date object here newPalanca return; }; </code></pre> <p>After all, my real question is: What format should I use to assign new values ​​to date type fields?</p> <p>Edit:</p> <p>After doing some tests, I noticed that if I assign a Date object to the property, everything seems fine until we got to this line:</p> <p>saveBundleStringified var = JSON.stringify (saveBundle);</p> <p>saveBundle content is:</p> <pre><code>FechaInicio: Thu Dec 20 2012 00:00:00 GMT+0100 (Hora estándar romance) </code></pre> <p>and the saveBundleStringified:</p> <pre><code>"FechaInicio": "2012-12-19T23:00:00.000Z" &lt;- I guess this is utc format </code></pre> <p>What finally is stored in the database is: 2012-12-19 23:00:00.0000000</p> <p>When the result of the call to SaveChanges are returned , they are merged with the entities in cache at the function updateEntity which does this check: if (!core.isDate(val)) that returns false. As a consequence it is created a new Date object with the wrong date:</p> <pre><code>function fastDateParse(y, m, d, h, i, s, ms){ //2012 12 19 23 00 00 "" return new Date(y, m - 1, d, h || 0, i || 0, s || 0, ms || 0); } </code></pre> <p>Correct me if I'm wrong, but I think that's the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload