GithubHelp home page GithubHelp logo

Comments (10)

nathanhoad avatar nathanhoad commented on August 16, 2024

Would you be able to give me an actual value for correctTime that I can test against?

I've tested the component inside a ReactNative app and the only way I can get it to say null is not an object (evaluating 'date.split') is by giving it Number("some string") or Number(undefined) as the time prop.

from react-timestamp.

pzehle avatar pzehle commented on August 16, 2024

Test is with this value, which is the one I'm getting from the API, in milliseconds: 1483041600000. I need to convert it to seconds in order to work with this module, otherwise I'm getting a date of year 4100~. Thanks!

from react-timestamp.

nathanhoad avatar nathanhoad commented on August 16, 2024

I get '30 Dec 2016' when I use Number(1483041600) as the time prop.

What version of react-timestamp are you using?

from react-timestamp.

pzehle avatar pzehle commented on August 16, 2024

Yes, if I hard-code the value it works fine, just please try to divide the value I gave you by 1000 and then use that result as the time prop.

from react-timestamp.

nathanhoad avatar nathanhoad commented on August 16, 2024

When I use this code:

    render() {
        var correctTime = 1483041600000;
        correctTime = Math.floor(correctTime / 1000);

        return (
            <View style={styles.container}>
                <Text>Value: {correctTime}</Text>
                <Time time={Number(correctTime)} format="date" component={Text} />
            </View>
        );
    }

I get this on screen:

screen shot 2017-05-16 at 9 08 02 am

from react-timestamp.

pzehle avatar pzehle commented on August 16, 2024

I'm doing exactly the same, but I'm using it inside a renderRow() function of a ListView, could you try that please?

from react-timestamp.

nathanhoad avatar nathanhoad commented on August 16, 2024

Components generally have no knowledge of their parent but just to make sure I tried rendering a ListView:

    renderRow (post) {
        var correctTime = Number(post.publish_date);
        correctTime = Math.floor(correctTime / 1000);
        
        return (
            <View style={styles.cell}>
                <Text style={styles.title}>{post.title}</Text>
                <Text>Value: {correctTime}</Text>
                <Time time={Number(correctTime)} format="date" component={Text} />
            </View>
        )
    }

And got this:

screen shot 2017-05-16 at 9 37 04 am

from react-timestamp.

pzehle avatar pzehle commented on August 16, 2024

Ok. Well, I'm still getting the same error, so you can close this issue if you want, and I'm going to keep looking for a solution, if I find anything else I'll let you know. Thanks again for you support.

from react-timestamp.

nathanhoad avatar nathanhoad commented on August 16, 2024

Ok I'll close it for now but feel free to comment back here if you find out any more info.

from react-timestamp.

pzehle avatar pzehle commented on August 16, 2024

Ok, thanks.

from react-timestamp.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.