Skip to content

Instantly share code, notes, and snippets.

@taylorbrooks
Last active February 20, 2016 22:39
Show Gist options
  • Save taylorbrooks/5c5148d6391c34cb067d to your computer and use it in GitHub Desktop.
Save taylorbrooks/5c5148d6391c34cb067d to your computer and use it in GitHub Desktop.
Set correct days.

This is a paid project. I'll accept answers in Ruby, Elixir, or NodeJS. Or all 3.

  • I need the project done by Saturday, February 27th.
  • DONE I'll pay $500 for the Ruby answer.
  • And $250 for an Elixir or Node answer.
# Before starting, please email me at:
e = "dGJyb29rc0BnbWFpbC5jb20="
Base64.decode64(e)

Project:

Write a method/function that will calculate an array of DateTimes that fall into the date/time window specified and have a moved forward by a minimum of the advance rules.

Window:

  • Monday-Thursday 9am-11am

Advance Rules:

  • start now
  • advance 2 days
  • advance 4 days
  • advance 1 week

Time should advance by some positive integer and either days, weeks, or months.

Example

e.g. Let's say the date is Saturday, February 20, 2016. And you want a result array that follows the rules above.

A correct result would be:

$irb> create_days(window_rules, advance_rules)
$irb> => [2016-02-22 09:11:53, 2016-02-24 10:14:53, 2016-02-29 09:38:00, 2016-03-07 09:11:53]

# Because the first date (now) is on a Saturday, `create_days`
# chooses the next available time within the window_rules
# or Monday, Feb. 22nd.

calendar

The solution should also take into account:

window inputs could be:

  • Monday, Wednesday 10am-10pm
  • Tuesday-Thursday, Sunday 8am-4pm

advance inputs could be:

  • [start now (regardless of whether "now" falls in the window), advance 2 days, advance 1 month, etc..]
@taylorbrooks
Copy link
Author

@joshcrews

  1. I will let you decide what the incoming args should looks like. Something I've done is pass in a ScheduleWindow object and an array that looks like ["Time.now", "2.days", "4.days", "1.week"]. But I'll leave that design decision open.
  2. Sorry that should be more explicit. Advancing should pick a random time between the time windows on the next available day.
  3. If the next date after an advance lands on a day outside of the window_rules, it should choose the next available date time. The demo shows this -- I'll be more explicit there too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment