node.js - Some code only works while chrome debugger is active -


i'm working on react-native application , i'm trying format date using moment.

dates "02-16-2016 09:04:23"

function formattime(date){    var formatteddate = moment(date).format('mm:ss a');    return formatteddate; } 

works fine if chrome debugger active. if disable it, "invalid date"

same thing decoding function i'm using

var = this; messagesservice.getmessagebody(selectedmessage)     .then(function(messagebody){          var decodeddata = window.atob(messagebody.messages);          that.setstate({           messagebody: decodeddata         })     })     .catch(function(err){         console.log(err);     }) 

displaying decoded data with

<text> body: {this.state.messagebody} </text> 

and displaying date with

<view style = {[messagestyles.senderitem, messagestyles.date]}>        <text>           {this.formattime(message.createdatetime)}        </text> </view> 

maybe bad way in react native? still learning doing bad practice.

i learned when using chrome debugger, react native uses different js engine. chrome js engine used during debugging, javascriptcore used otherwise. per article

http://ruoyusun.com/2015/11/01/things-i-wish-i-were-told-about-react-native.html

but actual issue dates, javascriptcore engine doesn't seem parsing dates -. had use regex expression replace - / , date manipulation worked fine.

02-16-2016 09:04:23 considered invalid

02/16/2016 09:04:23 considered valid


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -