steemit / steem-js

Steem.js the official JavaScript library for Steem blockchain
https://www.npmjs.com/package/steem
MIT License
472 stars 222 forks source link

steem.api.getDiscussionsByAuthorBeforeDate ignores the date #217

Open msg768 opened 7 years ago

msg768 commented 7 years ago

steem.api.getDiscussionsByAuthorBeforeDate(author, startPermlink, '2017-05-01T00:00:00', 10, function(err, result) { console.log(err, result); });

Expected behavior

It should return the latest 10 posts before 2017-05-01T00:00:00.

Actual behavior

It returns the latest 10 posts before now! The second parameter doesn't work properly either. If you try putting in the start of similar permlinks, it will return posts that do not start with startPermLink!

junkcoin commented 6 years ago

I have a similar problem with getDiscussionsByAuthorBeforeDate. startPermLink and beforeDate does not work!

powerpoint45 commented 6 years ago

You need to pass it a good date. Check out this example that works:

getAuthorPosts("adamkokesh", "");
getAuthorPosts("adamkokesh", "xog6wlno");
function getAuthorPosts(author, lastPermlink){
    var now = new Date();
    console.log(dateFormat(now, "yyyy-mm-dd'T'HH:MM:ss"));
    steem.api.getDiscussionsByAuthorBeforeDate(author,lastPermlink,dateFormat(now, "yyyy-mm-dd'T'HH:MM:ss"),5, function(err, result) {
          console.log(err,result);
    });
}

it starts by getting the first 5 posts and I have it hardcoded to get the next 5 based on a hardcoded permlink

date.format found here: http://stevenlevithan.com/assets/misc/date.format.js

azarus commented 6 years ago

dateFormat(now, "yyyy-mm-dd'T'HH:MM:ss") it starts by getting the first 5 posts and I have it hardcoded to get the next 5 based on a hardcoded > > permlink

date.format found here: http://stevenlevithan.com/assets/misc/date.format.js

Huh???

new Date().toJSON().substr(0, 19)

Produces:

"2018-01-01T13:24:02"

to generate permlink for post: new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase() + '-post',

to generate permlink for comment: steem.formatter.commentPermlink(author, permalink),

This work for me. Do you see any problems with this?

msg768 commented 5 years ago

You need to pass it a good date. Check out this example that works:

Can you tell me what's wrong with my date? You're sending the same format I'm sending as far as I can tell. You're also sending the current date so your exmple doesn't help because no matter what date I send in, it ignores it and instead uses the current date.

powerpoint45 commented 5 years ago

I think i meant that as a response to junkcoin. It's been a while..

bala-techguy commented 5 years ago

I guess the issue is still there. Did you find a solution for this @msg768 ?

powerpoint45 commented 5 months ago

Why is it that getDiscussionsByAuthorBeforeDate produces an error now no matter what the parameters? I'm getting : {"name":"RPCError","code":-32603,"data":{"error_id":"04b0b636-b655-472b-ad34-0eafdba62f08","jussi_request_id":"000664238044085943"}}