Skip to content

Conversation

@jeff-chastain
Copy link

Currently, a issue occurs where the iso8601Format flag is only being applied to the top level object properties and does not cascade, resulting in child date properties not being properly formatted.

Currently, a issue occurs where the iso8601Format flag is only being applied to the top level object properties and does not cascade, resulting in child date properties not being properly formatted.
@elpete elpete requested a review from lmajano January 17, 2023 23:46
@jclausen
Copy link
Contributor

I have not seen this behavicr with the application-level setting set for the module. Is this only happening when it is the default (non-ISO)?

@elpete
Copy link
Contributor

elpete commented Jan 18, 2023

@jclausen You are correct. We have a client that uses the old date formatting for legacy reasons, but we want new endpoints to use ISO8601.

@jeff-chastain
Copy link
Author

This is what I am seeing in one of the client APIs.

In this set of includes ... createdDate and modifiedDate are top level date/times and registerBy is a nested date/time ...

var includes = [
            "id",
            "interestedInInsurance",
            "trip.id",
            "trip.name",
            "trip.groupName",
            "trip.registerBy",
            "trip.pastReservationDate",
            "createdDate",
            "createdBy",
            "modifiedDate",
            "modifiedBy"
        ];

var reservationMementos = reservations.results.map( ( reservation ) => {
            return reservation.getMemento(
                includes = includes,
                ignoreDefaults = true,
                iso8601Format = true,
                mappers = {
                    // for some reason the id parameters are coming back as strings ... grr
                    "id": function( item, memento ) {
                        return toNumeric( item );
                    },
                    "tripId": function( item, memento ) {
                        return toNumeric( item );
                    }
                }
            );
        } );

And this is the resulting output ...

{
    "data": [
        {
            "interestedInInsurance": "false",
            "createdBy": "1BB80BEF-165C-46AE-9AD7-4E2439E9E7D7",
            "modifiedBy": "1BB80BEF-165C-46AE-9AD7-4E2439E9E7D7",
            "createdDate": "2023-01-06T15:28:05-06:00",
            "id": 9,
            "modifiedDate": "2023-01-06T15:28:05-06:00",
            "trip": {
                "pastReservationDate": false,
                "registerBy": "2023-06-01 00:00:00",
                "name": "My Test Trip",
                "id": 2,
                "groupName": "My Test Group"
            }
        }
    ]}

Note the difference in formatting for the createdDate/modifiedDate at the top level vs. the nested registerBy date.

@jeff-chastain jeff-chastain changed the title Update Mementifier.cfc Pass all of the getMemento() arguments in the child/recursive calls to address issue where nested dates are not formatted Jan 18, 2023
lmajano added a commit that referenced this pull request Jan 19, 2023
…o the top level object properties and does not cascade, resulting in child date properties not being properly formatted. #33

* `datemask` and `timeMask` arguments where not being params by default
@lmajano
Copy link
Contributor

lmajano commented Jan 19, 2023

This is approved, but I had to refactor some things manually. Please check out the commit here: 5a1330d

Basically, it has to use the incoming arguments and not the thisMmento because if not, any overrides would never cascade to the children. The arguments become the central authority as it takes into account the lookup of those arguments via instance setting > global setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants