SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Sample availabilities
  3. //
  4.  
  5. [{
  6.   userId: 1,
  7.   startTime: new Date("2019-04-12T15:00:00-02:00"),
  8.   durationInSec: 10800,
  9. }, {
  10.   userId: 2,
  11.   startTime: new Date("2019-04-12T13:00:00-02:00"),
  12.   durationInSec: 21600,
  13. }, {
  14.   userId: 3,
  15.   startTime: new Date("2019-04-13T12:00:00-02:00"),
  16.   durationInSec: 10800,
  17. }, {
  18.   userId: 4,
  19.   startTime: new Date("2019-04-13T12:00:00-02:00"),
  20.   durationInSec: 10800,
  21. }, {
  22.   userId: 5,
  23.   startTime: new Date("2019-04-14T12:00:00-02:00"),
  24.   durationInSec: 7200,
  25. }, {
  26.   userId: 3,
  27.   startTime: new Date("2019-04-14T12:00:00-02:00"),
  28.   durationInSec: 10800,
  29. }]
  30.  
  31. //
  32. // Write function:
  33. //
  34. function bucketAvailabilities(availabilities) {
  35.   // returns
  36.   // [{
  37.   //   userId: 3,
  38.   //   startTime: "2019-04-13T13:00:00-02:00",
  39.   //   durationInSec: 10800,
  40.   //   day: <day>,
  41.   //   column: 0 | 1 | 2 | 3 | 4 . . .,
  42.   // }]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top