question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature request: GetPriorOccurrence

See original GitHub issue

Would you please consider returning the return the DateTime when a task would have been due going back in time.

I am currently using the real hack

_expression.GetOccurrences(scheduled.AddDays(-60), scheduled, _timeZoneInfo, false, false).Last();

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:15
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
RZenicommented, Feb 22, 2022

This was the workaround that worked best for me. In my case a default of 1 month ago was sufficient, a more general use case probably wants a null default.

`

public DateTime GetPreviousOccurence(string cronString)
{
    var expression = CronExpression.Parse(cronString);
    var nextCron = expression.GetNextOccurrence(DateTime.UtcNow);

    if (nextCron == null) return DateTime.Now.AddMonths(-1);
    var upperBound = expression.GetNextOccurrence(nextCron.Value);

    if (upperBound == null) return DateTime.Now.AddMonths(-1);
    var difference = upperBound.Value.Subtract(nextCron.Value);

    return DateTime.Now.Subtract(difference);
}

`

2reactions
odinserjcommented, May 26, 2021

Please describe the idea behind this feature – we need to understand when it’s required, because usually we are iterating forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Manage Feature Requests [Template included]
This guide will teach you everything you need to know about feature requests – how to process them, manage them, respond to them,...
Read more >
How to Prioritize Feature Requests - Savio
Have a massive list of feature requests from your customers? Prioritize the most important features using this system.
Read more >
Feature Requests - Socrata Support - Data & Insights
My feature request status is “Planned.” Now what? Feature requests. Data & Insights has been built around the needs of our clients. If...
Read more >
Which Feature Request Prioritization Framework Should ...
Choosing the right feature request prioritization framework enables teams to make informed decisions and deliver the maximum customer value.
Read more >
7 Useful Tips to Manage Feature Requests
Managing feature requests can be one of the most challenging aspects of the product manager's role. In this post, we'll show you how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found