OData / OData/odataorg.github.io

DateTimeOffset handling in formatDateTimeOffset

Open
#197 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
73
Forks
106
PR merge metrics
No merged PRs in 30d

Description

We're using some DateTimeOffset datatypes in our MSSQL database and require the offset to be passed back to the server.

The function formatDateTimeOffset performs a hasOffset check on the value passed in but this only receives a DateTime from what I have seen. The means it never returns a DateTimeOffset from the function and we can't receive the correct value back on the server.

The check it performs on the value is the following snippet of code and it assumes fields that the parameter never has.

var isDateTimeOffset = function (value) {
        /// <summary>Checks whether a Date object is DateTimeOffset value</summary>
        /// <param name="value" type="Date" mayBeNull="false">Value to check.</param>
        /// <returns type="Boolean">true if the value is a DateTimeOffset, false otherwise.</returns>
        return (value.__edmType === "Edm.DateTimeOffset" || (!value.__edmType && value.__offset));
    };

I can hack around this but I am wondering if there is some setup missing from somewhere to get DateTimeOffsets to play nicely with the BreezeJS and DataJs frameworks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the formatDateTimeOffset function and its isDateTimeOffset check, then trace how DateTimeOffset values pass through BreezeJS and DataJs. Reproduce the MSSQL case and verify that the offset is preserved when the value is sent back to the server.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.