Is the date alphabetical?

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











up vote
5
down vote

favorite












Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.



An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:



September 26th 2018 -> September twenty-sixth two thousand eighteen

September
Twenty-sixth
Two thousand eighteen


Another way to think of this challenge: "are the elements of a given date lexically sorted?"



Notes:



  • 2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight."

  • 26th is represented as "twenty-sixth," not "twenty-six."

  • Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.

The following dates are not alphabetical:



  • September 2nd 2018 ("second" should sort ahead of "September")

  • April 30th 4000 ("four thousand" should sort ahead of "thirtieth")

Additional Rules:



  • You will receive the date as a string, formatted like YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).

  • You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year two nine thousand...").

  • You should return a truthy or falsey value, not necessarily a boolean True or False. If you do this in Javascript and want to return '0' and 0 that's fine. Of course, if you want to return a boolean, feel free.

  • Standard loopholes are forbidden.

  • This is code-golf

More Examples of Alphabetical Dates



  • 2066-01-02 (January second, two thousand sixty-six)

  • 1000-04-08 (April eighth, one thousand)

  • 6000-08-01 (August first, six thousand)

More Examples of Non-Alphabetical Dates



  • 1066-01-02 (January second, one thousand sixty-six)

  • 1000-04-07 (April seventh, one thousand)

  • 8000-08-01 (August first, eight thousand)









share|improve this question



















  • 1




    Lousy Smarch weather.
    – AdmBorkBork
    2 hours ago










  • @Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).
    – Erik the Outgolfer
    2 hours ago










  • @EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)
    – Arnauld
    2 hours ago










  • @Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!
    – souldeux
    2 hours ago














up vote
5
down vote

favorite












Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.



An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:



September 26th 2018 -> September twenty-sixth two thousand eighteen

September
Twenty-sixth
Two thousand eighteen


Another way to think of this challenge: "are the elements of a given date lexically sorted?"



Notes:



  • 2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight."

  • 26th is represented as "twenty-sixth," not "twenty-six."

  • Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.

The following dates are not alphabetical:



  • September 2nd 2018 ("second" should sort ahead of "September")

  • April 30th 4000 ("four thousand" should sort ahead of "thirtieth")

Additional Rules:



  • You will receive the date as a string, formatted like YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).

  • You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year two nine thousand...").

  • You should return a truthy or falsey value, not necessarily a boolean True or False. If you do this in Javascript and want to return '0' and 0 that's fine. Of course, if you want to return a boolean, feel free.

  • Standard loopholes are forbidden.

  • This is code-golf

More Examples of Alphabetical Dates



  • 2066-01-02 (January second, two thousand sixty-six)

  • 1000-04-08 (April eighth, one thousand)

  • 6000-08-01 (August first, six thousand)

More Examples of Non-Alphabetical Dates



  • 1066-01-02 (January second, one thousand sixty-six)

  • 1000-04-07 (April seventh, one thousand)

  • 8000-08-01 (August first, eight thousand)









share|improve this question



















  • 1




    Lousy Smarch weather.
    – AdmBorkBork
    2 hours ago










  • @Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).
    – Erik the Outgolfer
    2 hours ago










  • @EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)
    – Arnauld
    2 hours ago










  • @Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!
    – souldeux
    2 hours ago












up vote
5
down vote

favorite









up vote
5
down vote

favorite











Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.



An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:



September 26th 2018 -> September twenty-sixth two thousand eighteen

September
Twenty-sixth
Two thousand eighteen


Another way to think of this challenge: "are the elements of a given date lexically sorted?"



Notes:



  • 2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight."

  • 26th is represented as "twenty-sixth," not "twenty-six."

  • Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.

The following dates are not alphabetical:



  • September 2nd 2018 ("second" should sort ahead of "September")

  • April 30th 4000 ("four thousand" should sort ahead of "thirtieth")

Additional Rules:



  • You will receive the date as a string, formatted like YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).

  • You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year two nine thousand...").

  • You should return a truthy or falsey value, not necessarily a boolean True or False. If you do this in Javascript and want to return '0' and 0 that's fine. Of course, if you want to return a boolean, feel free.

  • Standard loopholes are forbidden.

  • This is code-golf

More Examples of Alphabetical Dates



  • 2066-01-02 (January second, two thousand sixty-six)

  • 1000-04-08 (April eighth, one thousand)

  • 6000-08-01 (August first, six thousand)

More Examples of Non-Alphabetical Dates



  • 1066-01-02 (January second, one thousand sixty-six)

  • 1000-04-07 (April seventh, one thousand)

  • 8000-08-01 (August first, eight thousand)









share|improve this question















Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.



An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:



September 26th 2018 -> September twenty-sixth two thousand eighteen

September
Twenty-sixth
Two thousand eighteen


Another way to think of this challenge: "are the elements of a given date lexically sorted?"



Notes:



  • 2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight."

  • 26th is represented as "twenty-sixth," not "twenty-six."

  • Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.

The following dates are not alphabetical:



  • September 2nd 2018 ("second" should sort ahead of "September")

  • April 30th 4000 ("four thousand" should sort ahead of "thirtieth")

Additional Rules:



  • You will receive the date as a string, formatted like YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).

  • You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year two nine thousand...").

  • You should return a truthy or falsey value, not necessarily a boolean True or False. If you do this in Javascript and want to return '0' and 0 that's fine. Of course, if you want to return a boolean, feel free.

  • Standard loopholes are forbidden.

  • This is code-golf

More Examples of Alphabetical Dates



  • 2066-01-02 (January second, two thousand sixty-six)

  • 1000-04-08 (April eighth, one thousand)

  • 6000-08-01 (August first, six thousand)

More Examples of Non-Alphabetical Dates



  • 1066-01-02 (January second, one thousand sixty-six)

  • 1000-04-07 (April seventh, one thousand)

  • 8000-08-01 (August first, eight thousand)






code-golf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 2 hours ago









souldeux

1896




1896







  • 1




    Lousy Smarch weather.
    – AdmBorkBork
    2 hours ago










  • @Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).
    – Erik the Outgolfer
    2 hours ago










  • @EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)
    – Arnauld
    2 hours ago










  • @Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!
    – souldeux
    2 hours ago












  • 1




    Lousy Smarch weather.
    – AdmBorkBork
    2 hours ago










  • @Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).
    – Erik the Outgolfer
    2 hours ago










  • @EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)
    – Arnauld
    2 hours ago










  • @Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!
    – souldeux
    2 hours ago







1




1




Lousy Smarch weather.
– AdmBorkBork
2 hours ago




Lousy Smarch weather.
– AdmBorkBork
2 hours ago












@Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).
– Erik the Outgolfer
2 hours ago




@Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).
– Erik the Outgolfer
2 hours ago












@EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)
– Arnauld
2 hours ago




@EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)
– Arnauld
2 hours ago












@Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!
– souldeux
2 hours ago




@Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!
– souldeux
2 hours ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote













JavaScript (ES6), 102 bytes



Saved 4 bytes thanks to @Shaggy



Returns $0$ or $1$.





s=>'_414044406550'[[,m,d]=s.split`-`,+m]<(d=`_268328715819832871$6e10-188`[+d])&d<'_6A9338704'[s[0]]


Try it online!






share|improve this answer






















  • 104 bytes
    – Shaggy
    1 hour ago










  • @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
    – Arnauld
    1 hour ago


















up vote
0
down vote













Wolfram Language 160 bytes



Returns True or False.



(t=ToExpression;i=IntegerName;d=StringSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]/.m_,d_,y_:> m,i@t@d,t@y~i~"Words";d==Sort@d)&


Explanation, in steps



StrtingSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]&["2018-09-26"]



returns



"September", "26", "2018"



/.m_,d_,y_:> m,IntegerName@ToExpression@d,ToExpression@y~IntegerName~"Words"



replaces the output with



"September", "twenty-six", "two thousand, eighteen"



and assigns this list of strings to d.



d=Sort@d returns True if the list, d, is lexically sorted; otherwise it returns False.






share|improve this answer




















    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%2f172847%2fis-the-date-alphabetical%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    JavaScript (ES6), 102 bytes



    Saved 4 bytes thanks to @Shaggy



    Returns $0$ or $1$.





    s=>'_414044406550'[[,m,d]=s.split`-`,+m]<(d=`_268328715819832871$6e10-188`[+d])&d<'_6A9338704'[s[0]]


    Try it online!






    share|improve this answer






















    • 104 bytes
      – Shaggy
      1 hour ago










    • @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
      – Arnauld
      1 hour ago















    up vote
    2
    down vote













    JavaScript (ES6), 102 bytes



    Saved 4 bytes thanks to @Shaggy



    Returns $0$ or $1$.





    s=>'_414044406550'[[,m,d]=s.split`-`,+m]<(d=`_268328715819832871$6e10-188`[+d])&d<'_6A9338704'[s[0]]


    Try it online!






    share|improve this answer






















    • 104 bytes
      – Shaggy
      1 hour ago










    • @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
      – Arnauld
      1 hour ago













    up vote
    2
    down vote










    up vote
    2
    down vote









    JavaScript (ES6), 102 bytes



    Saved 4 bytes thanks to @Shaggy



    Returns $0$ or $1$.





    s=>'_414044406550'[[,m,d]=s.split`-`,+m]<(d=`_268328715819832871$6e10-188`[+d])&d<'_6A9338704'[s[0]]


    Try it online!






    share|improve this answer














    JavaScript (ES6), 102 bytes



    Saved 4 bytes thanks to @Shaggy



    Returns $0$ or $1$.





    s=>'_414044406550'[[,m,d]=s.split`-`,+m]<(d=`_268328715819832871$6e10-188`[+d])&d<'_6A9338704'[s[0]]


    Try it online!







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 10 mins ago

























    answered 1 hour ago









    Arnauld

    65k581274




    65k581274











    • 104 bytes
      – Shaggy
      1 hour ago










    • @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
      – Arnauld
      1 hour ago

















    • 104 bytes
      – Shaggy
      1 hour ago










    • @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
      – Arnauld
      1 hour ago
















    104 bytes
    – Shaggy
    1 hour ago




    104 bytes
    – Shaggy
    1 hour ago












    @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
    – Arnauld
    1 hour ago





    @Shaggy Oops... This m= was, of course, completely useless. Thanks. :)
    – Arnauld
    1 hour ago











    up vote
    0
    down vote













    Wolfram Language 160 bytes



    Returns True or False.



    (t=ToExpression;i=IntegerName;d=StringSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]/.m_,d_,y_:> m,i@t@d,t@y~i~"Words";d==Sort@d)&


    Explanation, in steps



    StrtingSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]&["2018-09-26"]



    returns



    "September", "26", "2018"



    /.m_,d_,y_:> m,IntegerName@ToExpression@d,ToExpression@y~IntegerName~"Words"



    replaces the output with



    "September", "twenty-six", "two thousand, eighteen"



    and assigns this list of strings to d.



    d=Sort@d returns True if the list, d, is lexically sorted; otherwise it returns False.






    share|improve this answer
























      up vote
      0
      down vote













      Wolfram Language 160 bytes



      Returns True or False.



      (t=ToExpression;i=IntegerName;d=StringSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]/.m_,d_,y_:> m,i@t@d,t@y~i~"Words";d==Sort@d)&


      Explanation, in steps



      StrtingSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]&["2018-09-26"]



      returns



      "September", "26", "2018"



      /.m_,d_,y_:> m,IntegerName@ToExpression@d,ToExpression@y~IntegerName~"Words"



      replaces the output with



      "September", "twenty-six", "two thousand, eighteen"



      and assigns this list of strings to d.



      d=Sort@d returns True if the list, d, is lexically sorted; otherwise it returns False.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Wolfram Language 160 bytes



        Returns True or False.



        (t=ToExpression;i=IntegerName;d=StringSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]/.m_,d_,y_:> m,i@t@d,t@y~i~"Words";d==Sort@d)&


        Explanation, in steps



        StrtingSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]&["2018-09-26"]



        returns



        "September", "26", "2018"



        /.m_,d_,y_:> m,IntegerName@ToExpression@d,ToExpression@y~IntegerName~"Words"



        replaces the output with



        "September", "twenty-six", "two thousand, eighteen"



        and assigns this list of strings to d.



        d=Sort@d returns True if the list, d, is lexically sorted; otherwise it returns False.






        share|improve this answer












        Wolfram Language 160 bytes



        Returns True or False.



        (t=ToExpression;i=IntegerName;d=StringSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]/.m_,d_,y_:> m,i@t@d,t@y~i~"Words";d==Sort@d)&


        Explanation, in steps



        StrtingSplit@DateString[Interpreter["Date"]@#,"MonthName"," ","Day"," ","Year"]&["2018-09-26"]



        returns



        "September", "26", "2018"



        /.m_,d_,y_:> m,IntegerName@ToExpression@d,ToExpression@y~IntegerName~"Words"



        replaces the output with



        "September", "twenty-six", "two thousand, eighteen"



        and assigns this list of strings to d.



        d=Sort@d returns True if the list, d, is lexically sorted; otherwise it returns False.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        DavidC

        23.5k243100




        23.5k243100



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172847%2fis-the-date-alphabetical%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke