changing the pedometer Date function to time function


#1

hello ,
i’m a beginner to react-native and and am working on developing a pedometer app.
am able to get the step count successfully and am trying to store it in the async storage.
But i trying to figure it out that is it possible that instead of taking Date() function

const end = new Date();
    const start = new Date();
    start.setDate(end.getDate() - 1);
    Pedometer.getStepCountAsync(start, end).then(
      result => {
        this.setState({ pastStepCount: result.steps });
      },
      error => {
        this.setState({
          pastStepCount: "Could not get stepCount: " + error
        });
      }

instead of date, can we use any time() function, does react native support this?
what am trying to figure out is, i need step count for particular amount of time, like for ten min,person walks, he takes rest for some amount of time , then again he walks,
can that be possible?
thank you in advance


#2

Hey @hmadugula,

Welcome to the wonderful world of Expo and react-native! You can make use of any of these Date methods listed here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

You’ll probably want to write timestamps to your backend to mark when the user ceases movement and begins moving again so you can calculate step count for a given time period.

Cheers,

Adam


#3

@adamjnav thanks adam, i have tried some of those date methods but am not sure how to use them particularly,
even expo snack’s android machine is down, only IOS simulator is working and one more thing is Expo Android app is able to able to scan the QR code but it’snt working.
it used work good before the recent update of the expo app


#4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.