Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Date strings being rewritten

Discussion in 'Unity Remote Config' started by dri_richard, Aug 12, 2020.

  1. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    We use Remote Config 1.0.9 and I've upgraded to 1.2.3 so that I can specify a non-default environment, because we make builds for internal review without the Development flag set, whereas I want to use the Development environment.

    However, I've noticed that settings that contain date strings such as "2020-06-12T00:00:00Z" are now coming through as "06/12/2020 00:00:00", whereas previously they would have come through transparently.

    I don't think this is a documented change.

    Do you have any suggestions on how to parse these strings? I'm based in the UK, but it looks like a mm/dd/yyyy format is being used, so I'm wary of assuming that the locally set culture is being used in the conversion.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you share the code that you are using and a screenshot of your settings? We will take a look.
     
  3. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    The code is
    string dateTimeString = RemoteConfigHandler.GetString("StartDate", DateTime.Today.ToString("yyyy-MM-dd\\THH:mm:ss\\Z"))

    where RemoteConfigHandler.GetString is defined as

    internal static string GetString(string key, string defaultValue = "")
    {
    return ConfigManager.appConfig.GetString(key, defaultValue);
    }


    RemoteConfig.jpg
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, I am seeing the same thing. I will let the team know. You can also view the issue in the Remote Config editor by doing a Push of the string value followed by a Pull
     
    dri_richard likes this.
  5. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    Thanks.
    I've been using the web dashboard exclusively as the editor is often blank for me - see screenshot.
     

    Attached Files:

  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please compare to a new/empty project with RC enabled and start a new thread for this separate issue, thanks.
     
  7. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    37
    Hi @dri_richard ,
    Thanks for finding this bug!
    The reason for this strange behavior is that we used Json.Net library after 1.0.9, which converts any string in date format, interpreting strings as dates by default. That surprised us as well, and we fixed this for the Date field but forgot to assume that someone could use settings of type string as dates (which is your case).
    This very issue inflamed some discussions for otherwise excellent Json.Net library (https://github.com/JamesNK/Newtonsoft.Json/issues/862) as it was unexpected behavior for many other Json.net connoisseurs.

    We will add this fix ASAP, both in 1.2.x and 1.3.x versions of the package.
     
    dri_richard likes this.
  8. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    37
    Hi @dri_richard ,
    Thanks again for finding this bug!
    We applied fix in 1.3.2-preview.9 and 1.2.4-preview.3 versions of the RC package.
    Let us know if it works for you.
     
  9. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    Hi

    Dates are fine, but we have some JSON stored as string values, and double quotes are now being replaced with backslahes, leaving it malformed.
     
  10. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    37
    Hi @dri_richard,
    Thanks for the feedback, and sorry for this unfortunate regression, we will fix that scenario as well in the next release,
    so string values will be able to have quotes and dates will stay unchanged.

    On the side note, in package versions 1.3.x we added JSON as a new setting type, so it became first-class citizen having validation window as well.

    By all means, we will let you as soon as this is fixed as you are using 1.2.x

    Thanks and sorry for the inconvenience,
    Vlatko
     
  11. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    37
    Hi @dri_richard
    Fix is deployed, so please try to use either 1.3.2-preview.10 and 1.2.4-preview.4

    Now you should be able to use double quotes in string fields and no date will be re-formatted.

    Thanks again for your cooperation on this issue.

    Vlatko
     

    Attached Files: