The Work Day Countdown

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I just had I genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.




The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.



As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.



The Input should be a specific date in the "unofficial" European standard format dd.MM.yyyy and must be today or a day in the future.



The Output should only be the number of days left.



As it's code-golf the shortest code wins.



Example:

Today is the 10.12.2018

The input is 17.12.2018

Result should be 5 because Saturday & Sunday is excluded.




If I missed a few things in the question, please forgive me - it's my first question :)










share|improve this question



















  • 2




    Is there any specific reason behind this "unofficial" European input format? Our consensus is to allow flexible input whenever possible.
    – Arnauld
    2 hours ago






  • 1




    @JonathanAllan yes you're right. I edit it.
    – Hille
    2 hours ago










  • @Arnauld because most of the date methods I know are in a specific format and I don't know any method which will use the dd.MM.yyyy immediately -> it may make the task a bit more challenging. May there are some disadvantages for some languages, but I don't know any language which will profit out of this rule :)
    – Hille
    2 hours ago







  • 1




    Is there really any point in adding the "extra challenge" of a hard to process date format? That just seems unfair w.r.t. languages that have flexible date formats...
    – Quintec
    47 mins ago






  • 1




    @Hille I did not say it was "hard", it just is an unnecessary hassle, especially in code-golf...do note the link that Arnauld posted above... generally flexible input is the norm...
    – Quintec
    42 mins ago














up vote
2
down vote

favorite












I just had I genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.




The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.



As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.



The Input should be a specific date in the "unofficial" European standard format dd.MM.yyyy and must be today or a day in the future.



The Output should only be the number of days left.



As it's code-golf the shortest code wins.



Example:

Today is the 10.12.2018

The input is 17.12.2018

Result should be 5 because Saturday & Sunday is excluded.




If I missed a few things in the question, please forgive me - it's my first question :)










share|improve this question



















  • 2




    Is there any specific reason behind this "unofficial" European input format? Our consensus is to allow flexible input whenever possible.
    – Arnauld
    2 hours ago






  • 1




    @JonathanAllan yes you're right. I edit it.
    – Hille
    2 hours ago










  • @Arnauld because most of the date methods I know are in a specific format and I don't know any method which will use the dd.MM.yyyy immediately -> it may make the task a bit more challenging. May there are some disadvantages for some languages, but I don't know any language which will profit out of this rule :)
    – Hille
    2 hours ago







  • 1




    Is there really any point in adding the "extra challenge" of a hard to process date format? That just seems unfair w.r.t. languages that have flexible date formats...
    – Quintec
    47 mins ago






  • 1




    @Hille I did not say it was "hard", it just is an unnecessary hassle, especially in code-golf...do note the link that Arnauld posted above... generally flexible input is the norm...
    – Quintec
    42 mins ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I just had I genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.




The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.



As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.



The Input should be a specific date in the "unofficial" European standard format dd.MM.yyyy and must be today or a day in the future.



The Output should only be the number of days left.



As it's code-golf the shortest code wins.



Example:

Today is the 10.12.2018

The input is 17.12.2018

Result should be 5 because Saturday & Sunday is excluded.




If I missed a few things in the question, please forgive me - it's my first question :)










share|improve this question















I just had I genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.




The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.



As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.



The Input should be a specific date in the "unofficial" European standard format dd.MM.yyyy and must be today or a day in the future.



The Output should only be the number of days left.



As it's code-golf the shortest code wins.



Example:

Today is the 10.12.2018

The input is 17.12.2018

Result should be 5 because Saturday & Sunday is excluded.




If I missed a few things in the question, please forgive me - it's my first question :)







code-golf date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 2 hours ago









Hille

1498




1498







  • 2




    Is there any specific reason behind this "unofficial" European input format? Our consensus is to allow flexible input whenever possible.
    – Arnauld
    2 hours ago






  • 1




    @JonathanAllan yes you're right. I edit it.
    – Hille
    2 hours ago










  • @Arnauld because most of the date methods I know are in a specific format and I don't know any method which will use the dd.MM.yyyy immediately -> it may make the task a bit more challenging. May there are some disadvantages for some languages, but I don't know any language which will profit out of this rule :)
    – Hille
    2 hours ago







  • 1




    Is there really any point in adding the "extra challenge" of a hard to process date format? That just seems unfair w.r.t. languages that have flexible date formats...
    – Quintec
    47 mins ago






  • 1




    @Hille I did not say it was "hard", it just is an unnecessary hassle, especially in code-golf...do note the link that Arnauld posted above... generally flexible input is the norm...
    – Quintec
    42 mins ago












  • 2




    Is there any specific reason behind this "unofficial" European input format? Our consensus is to allow flexible input whenever possible.
    – Arnauld
    2 hours ago






  • 1




    @JonathanAllan yes you're right. I edit it.
    – Hille
    2 hours ago










  • @Arnauld because most of the date methods I know are in a specific format and I don't know any method which will use the dd.MM.yyyy immediately -> it may make the task a bit more challenging. May there are some disadvantages for some languages, but I don't know any language which will profit out of this rule :)
    – Hille
    2 hours ago







  • 1




    Is there really any point in adding the "extra challenge" of a hard to process date format? That just seems unfair w.r.t. languages that have flexible date formats...
    – Quintec
    47 mins ago






  • 1




    @Hille I did not say it was "hard", it just is an unnecessary hassle, especially in code-golf...do note the link that Arnauld posted above... generally flexible input is the norm...
    – Quintec
    42 mins ago







2




2




Is there any specific reason behind this "unofficial" European input format? Our consensus is to allow flexible input whenever possible.
– Arnauld
2 hours ago




Is there any specific reason behind this "unofficial" European input format? Our consensus is to allow flexible input whenever possible.
– Arnauld
2 hours ago




1




1




@JonathanAllan yes you're right. I edit it.
– Hille
2 hours ago




@JonathanAllan yes you're right. I edit it.
– Hille
2 hours ago












@Arnauld because most of the date methods I know are in a specific format and I don't know any method which will use the dd.MM.yyyy immediately -> it may make the task a bit more challenging. May there are some disadvantages for some languages, but I don't know any language which will profit out of this rule :)
– Hille
2 hours ago





@Arnauld because most of the date methods I know are in a specific format and I don't know any method which will use the dd.MM.yyyy immediately -> it may make the task a bit more challenging. May there are some disadvantages for some languages, but I don't know any language which will profit out of this rule :)
– Hille
2 hours ago





1




1




Is there really any point in adding the "extra challenge" of a hard to process date format? That just seems unfair w.r.t. languages that have flexible date formats...
– Quintec
47 mins ago




Is there really any point in adding the "extra challenge" of a hard to process date format? That just seems unfair w.r.t. languages that have flexible date formats...
– Quintec
47 mins ago




1




1




@Hille I did not say it was "hard", it just is an unnecessary hassle, especially in code-golf...do note the link that Arnauld posted above... generally flexible input is the norm...
– Quintec
42 mins ago




@Hille I did not say it was "hard", it just is an unnecessary hassle, especially in code-golf...do note the link that Arnauld posted above... generally flexible input is the norm...
– Quintec
42 mins ago










4 Answers
4






active

oldest

votes

















up vote
2
down vote














Red, 72 bytes



func[a][b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


Try it online!



Takes the date in format dd-mm-yyyy, for example 31-10-2018 (also works with 10-Oct-2018)



Strict input:




Red, 97 bytes



func[a][a: do replace/all a".""-"b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


Try it online!



Bonus:



Returns a list of the dates/weekdays of the working days up to the given date:




Red, 235 bytes



f: func [ a ] [
b: now/date
d: system/locale/days
collect [
until [
if b/weekday < 6 [
keep/only reduce [ b ":" d/(b/weekday) ]
]
a < b: b + 1
]
]
]


Try it online!






share|improve this answer






















  • Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
    – Quintec
    58 mins ago






  • 1




    Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
    – Galen Ivanov
    56 mins ago






  • 1




    90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
    – Quintec
    53 mins ago






  • 1




    @KevinCruijssen - I added a version with the strict input rules taken into consideration
    – Galen Ivanov
    25 mins ago

















up vote
2
down vote














R, 76 bytes





sum(!grepl("S",weekdays(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1))))+1


Try it online!



weekdays gives text days of week, so we count the days in the sequence between today and the input that do not contain S, and add one to the result.






share|improve this answer



























    up vote
    2
    down vote














    Wolfram Language (Mathematica), 64 bytes



    DayCount[Today,DateObject@#,"Day","Month","Year","Weekday"]&


    Try it online!



    DayCount[x,y,"Weekday"] counts the number of weekdays between xand y.



    For many inputs, this could be the 28-byte DayCount[Today,#,"Weekday"]&, but Mathematica tries to interpret an input "xx.yy.zzzz" as mm.dd.yyyy whenever it's possible, and then it complains about the input being ambiguous. Its second choice is the European format, so the shorter code still gets it right most of the time.






    share|improve this answer



























      up vote
      0
      down vote














      JavaScript (Node.js), 168 160 bytes



      8 bytes less thanks to quintec



      My own submission is a bit longer but it made fun for me to make :)





      function f(D)var i=D.split('.'),n=0;for(var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)n++;return n;


      Try it online!



      Btw I'm new to JS so please excuse some mistakes and please help me to improve my submission.



      function f(D)
      // Splitting the input date into an array
      var i=D.split('.'),n=0;
      // Foreach day between now and the date
      for (var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))
      // If the day is not a saturday or a sunday
      if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)
      // Count one up
      n++;
      // Return the counter
      return n;


      print(f('16.10.2018'));





      share|improve this answer


















      • 1




        158 bytes with lambda
        – Quintec
        8 mins ago







      • 1




        139 bytes with improved if condition
        – Quintec
        3 mins ago










      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "200"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173104%2fthe-work-day-countdown%23new-answer', 'question_page');

      );

      Post as a guest






























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote














      Red, 72 bytes



      func[a][b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Takes the date in format dd-mm-yyyy, for example 31-10-2018 (also works with 10-Oct-2018)



      Strict input:




      Red, 97 bytes



      func[a][a: do replace/all a".""-"b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Bonus:



      Returns a list of the dates/weekdays of the working days up to the given date:




      Red, 235 bytes



      f: func [ a ] [
      b: now/date
      d: system/locale/days
      collect [
      until [
      if b/weekday < 6 [
      keep/only reduce [ b ":" d/(b/weekday) ]
      ]
      a < b: b + 1
      ]
      ]
      ]


      Try it online!






      share|improve this answer






















      • Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
        – Quintec
        58 mins ago






      • 1




        Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
        – Galen Ivanov
        56 mins ago






      • 1




        90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
        – Quintec
        53 mins ago






      • 1




        @KevinCruijssen - I added a version with the strict input rules taken into consideration
        – Galen Ivanov
        25 mins ago














      up vote
      2
      down vote














      Red, 72 bytes



      func[a][b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Takes the date in format dd-mm-yyyy, for example 31-10-2018 (also works with 10-Oct-2018)



      Strict input:




      Red, 97 bytes



      func[a][a: do replace/all a".""-"b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Bonus:



      Returns a list of the dates/weekdays of the working days up to the given date:




      Red, 235 bytes



      f: func [ a ] [
      b: now/date
      d: system/locale/days
      collect [
      until [
      if b/weekday < 6 [
      keep/only reduce [ b ":" d/(b/weekday) ]
      ]
      a < b: b + 1
      ]
      ]
      ]


      Try it online!






      share|improve this answer






















      • Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
        – Quintec
        58 mins ago






      • 1




        Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
        – Galen Ivanov
        56 mins ago






      • 1




        90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
        – Quintec
        53 mins ago






      • 1




        @KevinCruijssen - I added a version with the strict input rules taken into consideration
        – Galen Ivanov
        25 mins ago












      up vote
      2
      down vote










      up vote
      2
      down vote










      Red, 72 bytes



      func[a][b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Takes the date in format dd-mm-yyyy, for example 31-10-2018 (also works with 10-Oct-2018)



      Strict input:




      Red, 97 bytes



      func[a][a: do replace/all a".""-"b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Bonus:



      Returns a list of the dates/weekdays of the working days up to the given date:




      Red, 235 bytes



      f: func [ a ] [
      b: now/date
      d: system/locale/days
      collect [
      until [
      if b/weekday < 6 [
      keep/only reduce [ b ":" d/(b/weekday) ]
      ]
      a < b: b + 1
      ]
      ]
      ]


      Try it online!






      share|improve this answer















      Red, 72 bytes



      func[a][b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Takes the date in format dd-mm-yyyy, for example 31-10-2018 (also works with 10-Oct-2018)



      Strict input:




      Red, 97 bytes



      func[a][a: do replace/all a".""-"b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]


      Try it online!



      Bonus:



      Returns a list of the dates/weekdays of the working days up to the given date:




      Red, 235 bytes



      f: func [ a ] [
      b: now/date
      d: system/locale/days
      collect [
      until [
      if b/weekday < 6 [
      keep/only reduce [ b ":" d/(b/weekday) ]
      ]
      a < b: b + 1
      ]
      ]
      ]


      Try it online!







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 26 mins ago

























      answered 1 hour ago









      Galen Ivanov

      4,9071929




      4,9071929











      • Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
        – Quintec
        58 mins ago






      • 1




        Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
        – Galen Ivanov
        56 mins ago






      • 1




        90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
        – Quintec
        53 mins ago






      • 1




        @KevinCruijssen - I added a version with the strict input rules taken into consideration
        – Galen Ivanov
        25 mins ago
















      • Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
        – Quintec
        58 mins ago






      • 1




        Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
        – Galen Ivanov
        56 mins ago






      • 1




        90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
        – Quintec
        53 mins ago






      • 1




        @KevinCruijssen - I added a version with the strict input rules taken into consideration
        – Galen Ivanov
        25 mins ago















      Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
      – Quintec
      58 mins ago




      Agh, no fair, in python I need to spend about 72 bytes processing this IO format... :P
      – Quintec
      58 mins ago




      1




      1




      Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
      – Galen Ivanov
      56 mins ago




      Usually my Red solutions are among the longest ones, but fortunately Red deals very well with dates :)
      – Galen Ivanov
      56 mins ago




      1




      1




      90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
      – Quintec
      53 mins ago




      90 bytes to process python... i'm done, I quit until there's a more flexible input format :P
      – Quintec
      53 mins ago




      1




      1




      @KevinCruijssen - I added a version with the strict input rules taken into consideration
      – Galen Ivanov
      25 mins ago




      @KevinCruijssen - I added a version with the strict input rules taken into consideration
      – Galen Ivanov
      25 mins ago










      up vote
      2
      down vote














      R, 76 bytes





      sum(!grepl("S",weekdays(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1))))+1


      Try it online!



      weekdays gives text days of week, so we count the days in the sequence between today and the input that do not contain S, and add one to the result.






      share|improve this answer
























        up vote
        2
        down vote














        R, 76 bytes





        sum(!grepl("S",weekdays(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1))))+1


        Try it online!



        weekdays gives text days of week, so we count the days in the sequence between today and the input that do not contain S, and add one to the result.






        share|improve this answer






















          up vote
          2
          down vote










          up vote
          2
          down vote










          R, 76 bytes





          sum(!grepl("S",weekdays(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1))))+1


          Try it online!



          weekdays gives text days of week, so we count the days in the sequence between today and the input that do not contain S, and add one to the result.






          share|improve this answer













          R, 76 bytes





          sum(!grepl("S",weekdays(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1))))+1


          Try it online!



          weekdays gives text days of week, so we count the days in the sequence between today and the input that do not contain S, and add one to the result.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 24 mins ago









          ngm

          2,32920




          2,32920




















              up vote
              2
              down vote














              Wolfram Language (Mathematica), 64 bytes



              DayCount[Today,DateObject@#,"Day","Month","Year","Weekday"]&


              Try it online!



              DayCount[x,y,"Weekday"] counts the number of weekdays between xand y.



              For many inputs, this could be the 28-byte DayCount[Today,#,"Weekday"]&, but Mathematica tries to interpret an input "xx.yy.zzzz" as mm.dd.yyyy whenever it's possible, and then it complains about the input being ambiguous. Its second choice is the European format, so the shorter code still gets it right most of the time.






              share|improve this answer
























                up vote
                2
                down vote














                Wolfram Language (Mathematica), 64 bytes



                DayCount[Today,DateObject@#,"Day","Month","Year","Weekday"]&


                Try it online!



                DayCount[x,y,"Weekday"] counts the number of weekdays between xand y.



                For many inputs, this could be the 28-byte DayCount[Today,#,"Weekday"]&, but Mathematica tries to interpret an input "xx.yy.zzzz" as mm.dd.yyyy whenever it's possible, and then it complains about the input being ambiguous. Its second choice is the European format, so the shorter code still gets it right most of the time.






                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote










                  Wolfram Language (Mathematica), 64 bytes



                  DayCount[Today,DateObject@#,"Day","Month","Year","Weekday"]&


                  Try it online!



                  DayCount[x,y,"Weekday"] counts the number of weekdays between xand y.



                  For many inputs, this could be the 28-byte DayCount[Today,#,"Weekday"]&, but Mathematica tries to interpret an input "xx.yy.zzzz" as mm.dd.yyyy whenever it's possible, and then it complains about the input being ambiguous. Its second choice is the European format, so the shorter code still gets it right most of the time.






                  share|improve this answer













                  Wolfram Language (Mathematica), 64 bytes



                  DayCount[Today,DateObject@#,"Day","Month","Year","Weekday"]&


                  Try it online!



                  DayCount[x,y,"Weekday"] counts the number of weekdays between xand y.



                  For many inputs, this could be the 28-byte DayCount[Today,#,"Weekday"]&, but Mathematica tries to interpret an input "xx.yy.zzzz" as mm.dd.yyyy whenever it's possible, and then it complains about the input being ambiguous. Its second choice is the European format, so the shorter code still gets it right most of the time.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 11 mins ago









                  Misha Lavrov

                  3,287320




                  3,287320




















                      up vote
                      0
                      down vote














                      JavaScript (Node.js), 168 160 bytes



                      8 bytes less thanks to quintec



                      My own submission is a bit longer but it made fun for me to make :)





                      function f(D)var i=D.split('.'),n=0;for(var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)n++;return n;


                      Try it online!



                      Btw I'm new to JS so please excuse some mistakes and please help me to improve my submission.



                      function f(D)
                      // Splitting the input date into an array
                      var i=D.split('.'),n=0;
                      // Foreach day between now and the date
                      for (var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))
                      // If the day is not a saturday or a sunday
                      if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)
                      // Count one up
                      n++;
                      // Return the counter
                      return n;


                      print(f('16.10.2018'));





                      share|improve this answer


















                      • 1




                        158 bytes with lambda
                        – Quintec
                        8 mins ago







                      • 1




                        139 bytes with improved if condition
                        – Quintec
                        3 mins ago














                      up vote
                      0
                      down vote














                      JavaScript (Node.js), 168 160 bytes



                      8 bytes less thanks to quintec



                      My own submission is a bit longer but it made fun for me to make :)





                      function f(D)var i=D.split('.'),n=0;for(var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)n++;return n;


                      Try it online!



                      Btw I'm new to JS so please excuse some mistakes and please help me to improve my submission.



                      function f(D)
                      // Splitting the input date into an array
                      var i=D.split('.'),n=0;
                      // Foreach day between now and the date
                      for (var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))
                      // If the day is not a saturday or a sunday
                      if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)
                      // Count one up
                      n++;
                      // Return the counter
                      return n;


                      print(f('16.10.2018'));





                      share|improve this answer


















                      • 1




                        158 bytes with lambda
                        – Quintec
                        8 mins ago







                      • 1




                        139 bytes with improved if condition
                        – Quintec
                        3 mins ago












                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote










                      JavaScript (Node.js), 168 160 bytes



                      8 bytes less thanks to quintec



                      My own submission is a bit longer but it made fun for me to make :)





                      function f(D)var i=D.split('.'),n=0;for(var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)n++;return n;


                      Try it online!



                      Btw I'm new to JS so please excuse some mistakes and please help me to improve my submission.



                      function f(D)
                      // Splitting the input date into an array
                      var i=D.split('.'),n=0;
                      // Foreach day between now and the date
                      for (var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))
                      // If the day is not a saturday or a sunday
                      if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)
                      // Count one up
                      n++;
                      // Return the counter
                      return n;


                      print(f('16.10.2018'));





                      share|improve this answer















                      JavaScript (Node.js), 168 160 bytes



                      8 bytes less thanks to quintec



                      My own submission is a bit longer but it made fun for me to make :)





                      function f(D)var i=D.split('.'),n=0;for(var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)n++;return n;


                      Try it online!



                      Btw I'm new to JS so please excuse some mistakes and please help me to improve my submission.



                      function f(D)
                      // Splitting the input date into an array
                      var i=D.split('.'),n=0;
                      // Foreach day between now and the date
                      for (var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))
                      // If the day is not a saturday or a sunday
                      if(d.getDay()<1?1<0:d.getDay()>5?1<0:1>0)
                      // Count one up
                      n++;
                      // Return the counter
                      return n;


                      print(f('16.10.2018'));






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 3 mins ago

























                      answered 18 mins ago









                      Hille

                      1498




                      1498







                      • 1




                        158 bytes with lambda
                        – Quintec
                        8 mins ago







                      • 1




                        139 bytes with improved if condition
                        – Quintec
                        3 mins ago












                      • 1




                        158 bytes with lambda
                        – Quintec
                        8 mins ago







                      • 1




                        139 bytes with improved if condition
                        – Quintec
                        3 mins ago







                      1




                      1




                      158 bytes with lambda
                      – Quintec
                      8 mins ago





                      158 bytes with lambda
                      – Quintec
                      8 mins ago





                      1




                      1




                      139 bytes with improved if condition
                      – Quintec
                      3 mins ago




                      139 bytes with improved if condition
                      – Quintec
                      3 mins ago

















                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173104%2fthe-work-day-countdown%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery