Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional DateTime variables are erroneously defaulted to current date & time #687

Open
martinhalford opened this issue Aug 16, 2021 · 1 comment
Assignees

Comments

@martinhalford
Copy link
Member

martinhalford commented Aug 16, 2021

Bug Report 馃悰

Details

Consider the following asset declaration.

asset HelloWorldClause extends Clause {
  o String name
  o DateTime date optional
}

As the DateTime date variable is optional then a user may, or may not, pass a value in via the data.json payload.

Example 1

Using the following data.json

{
    "$class": "org.accordproject.helloworld.HelloWorldClause",
    "name": "Fred Blogs",
    "date": "2021-01-01T00:00:00.000+00:00",
    "clauseId": "c69e70dd-81ea-491b-8714-1a7d984a5cae",
    "$identifier": "c69e70dd-81ea-491b-8714-1a7d984a5cae"
}

...the cicero draft command produces the following sample.md

Name of the person to greet: "Fred Blogs".
The date of this agreement is: 01/01/2021
Thank you!

...which is as expected.

Example 2

Using the following data.json which is missing the optional DateTime attribute, as allowed

{
    "$class": "org.accordproject.helloworld.HelloWorldClause",
    "name": "Fred Blogs",
    "clauseId": "c69e70dd-81ea-491b-8714-1a7d984a5cae",
    "$identifier": "c69e70dd-81ea-491b-8714-1a7d984a5cae"
}

...the cicero draft command incorrectly produces the following sample.md

Name of the person to greet: "Fred Blogs".
The date of this agreement is: 08/16/2021
Thank you!

...which is not as expected.

Cicero has incorrectly inserted the current date and time values in place of the undefined DateTime attribute.

Expected Example 2

What was expected was...

Name of the person to greet: "Fred Blogs".
The date of this agreement is: undefined
Thank you!

We'd expect the undefined optional DateTime variable to appear as undefined in the output MD files, in the same was as undefined String variables appear as undefined.

Why is this an issue

At the moment, we are unable to distinguish when an optional DateTime variable has been passed in via data.json and when an optional DateTime variable has legitimately been omitted.

Attached example HelloWorld CTA

helloworld.zip

@OmkarAcharekar
Copy link

OmkarAcharekar commented Jan 25, 2022

Hey @jeromesimeon @martinhalford, This issue can be solved by making few changes in dateTimeDrafter function in markdown-transform repo. This may work:

function dateTimeDrafter(value,format) {
     if(value){
          const f = format ? format : 'MM/DD/YYYY';
          return dayjs.utc(value).format(f);
     }else{
          return "undefined";
    }   
}

Should I submit a PR to that repo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants