Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:39:08+00:00 2026-06-11T18:39:08+00:00

s = 2/29/2010 how to validate the above string is a valid date in

  • 0

s = “2/29/2010”

how to validate the above string is a valid date in Lua?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:39:09+00:00Added an answer on June 11, 2026 at 6:39 pm

    There is no such thing in the standard Lua library, but can be easily created yourself:

    function is_valid_date(str)
    
      -- perhaps some sanity checks to see if `str` really is a date
    
      local m, d, y = str:match("(%d+)/(%d+)/(%d+)")
    
      m, d, y = tonumber(m), tonumber(d), tonumber(y)
    
      if d < 0 or d > 31 or m < 0 or m > 12 or y < 0 then
        -- Cases that don't make sense
        return false
      elseif m == 4 or m == 6 or m == 9 or m == 11 then 
        -- Apr, Jun, Sep, Nov can have at most 30 days
        return d <= 30
      elseif m == 2 then
        -- Feb
        if y%400 == 0 or (y%100 ~= 0 and y%4 == 0) then
          -- if leap year, days can be at most 29
          return d <= 29
        else
          -- else 28 days is the max
          return d <= 28
        end
      else 
        -- all other months can have at most 31 days
        return d <= 31
      end
    
    end
    

    (untested!)

    Or do a search for “lua date parsing” to find a 3rd party library that will do this for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i validate that the date and time in the following string is
How to validate particular format date string using Javascript? I have one date picker
I'm trying to validate date using PHP. I'd like following formats to be valid:
i want a regular expression to validate date of the kind 13/08/2010 how to
[{'date': '2010-04-01', 'people': 1047, 'hits': 4522}, {'date': '2010-04-03', 'people': 617, 'hits': 2582}, {'date': '2010-04-02',
Using javascript I need to validate a form field containing a date in the
I wanna validate date which can be either in short date format or long
...or Why do these files validate in Visual Studio 2010 but not with xmllint
We need help for regular expression that work with asp.net asp:RegularExpressionValidator to validate date
[2010-04-16 23:31:34 - MobileDataKeeper] Error in an XML file: aborting build. [2010-04-16 23:31:57 -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.