2

I have a date picker that is custom built by using static resources in lightning component. This is already existing and working fine. since the summer 17 update, it started throwing the error

"AuraLocalizationService.parseDateTime(): Locale 'undefined' is not available. Falls back to the locale in $Locale.langLocale: en_US".

I assume it is the error in the static resources. I dont see "AuraLocalizationService" anywhere in my lightning components or vf pages.

Wanted to get some insights on this?

Where do I start?

Screenshot: enter image description here

Update: 5/18

The calendar works fine but the manualdatechnage doesn't work. When I do a date change manually via input, the goes till the controller js but doesn't execute the helper. Not sure what I'm missing here. Follwoing are the components.

Input Components:

<aura:registerEvent name="dataChangeEvent" type="c:DateChange" description="The event fired when a valid date is set" />
    <aura:registerEvent name="onFocus" type="c:DateChangeEvent" description="The event fired when the user focuses on the component."/>


    <div class="form-element">
        <input type="text"
               aura:id="inputText"
               placeholder="{!v.placeholder}"
               value="{!v.value}"
               format="{!v.format}"
               class="{!v.class + ' input'}"
               onchange="{!c.handleDateChange}"
               onfocus="{!c.handleFocus}"/>

    </div>

Controller Js:

handleDateChange: function (component, event, helper) {
        console.dir('handledatechange***:'+helper);
        var value = event.target.value;
        console.log('inside controller:::'+value);
        helper.doUpdate(component, event);
    },

Helper:

doUpdate: function (component,event) {
    conosle.log('**event');
    //var value = event.getParam("value") || event.getParam("arguments").value;
    var value = event.target.value;
    if (!value) {
        return;
    }
    conosle.log('**event manual input**:'+value);
    var localizedValue = $A.localizationService.translateFromLocalizedDigits(value);
    var formattedDate = localizedValue;
    if (value) {
        var date = $A.localizationService.parseDateTimeUTC(localizedValue, this.format, true);

        if (date) {
            date = $A.localizationService.translateFromOtherCalendar(date);
            formattedDate = $A.localizationService.formatDateUTC(date, "YYYY-MM-DD");
            //fire event if value different from attribute value
            var currentValue = component.get("v.value");
            if (currentValue !== formattedDate){
                //emit an event!
                var dataChangeEvent = component.getEvent("dataChangeEvent");

                dataChangeEvent.setParams({"data" : {"value":formattedDate} });
                dataChangeEvent.fire();
            }
        }
    }
    component.set("v.value", formattedDate);
    console.log('formatted date:****'+formattedDate);
},

enter image description here

1

To answer your immediate question, this issue is directly caused by the ui:inputDate component provided by Salesforce. It's still using the locale parameter that has been deprecated in Summer 17.

The locale parameter is deprecated for several methods in the AuraLocalizationService object. The validation for the locale parameter has also been tightened to allow locale values to match only the user’s Language or Locale settings in Salesforce. If the locale parameter is set to another value, it defaults to the user’s Language setting.

See here in the Summer 17 Release Notes

The obvious fix for this is to not use the ui:inputDate component and I nearly have a replacement ready. When it is ready, I'll post it up to my github project. To see updates to this project, star or follow my library: Datepicker

| improve this answer | |
  • I have updated the question with my issue and corresponding code. Please look into to it. – Anurag May 18 '17 at 14:33
  • It's been fixed for a while. Grab all the code on the github project (including a couple of new components such as a datetime lib and a new inputDate component). Don't forget to update the Datepicker component too. It's all there and it all works. If you follow or star my project on github, it'll tell you when I make updates to the project. – Caspar Harmer May 18 '17 at 18:19
  • Glad it worked for you!! Note, if you deploy to prod, you'll have to ADD the locale param back in a couple of places until Summer 17 goes live (in about 3 weeks) – Caspar Harmer May 23 '17 at 23:52
  • Did salesforce make any chnage to "inputdate". I didn't deploy our new components for testing yet. It was broken in tetsing sandbox since it moved to summer '17. I didn't move my chnages yet, but the date picker started working in all spring and summer 17. Did salesforce revert back chnages to inputdate? Did you notice it? – Anurag May 24 '17 at 13:38
  • don't deploy your changes to production (although you can actually change prod lightning components). The reason is: Salesforce made two changes in the recent update. 1. ui:inputDate now displays it's own horrible native picker when you click into it and you can't turn that off. 2. the locale thing is not live yet in prod, so your fixes for it won't work yet. Not long to wait though! – Caspar Harmer May 24 '17 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.