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

  • Home
  • SEARCH
  • 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 6175989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:01:15+00:00 2026-05-24T00:01:15+00:00

I am using boost optionsparser to parse the command-line arguments passed by the user.

  • 0

I am using boost optionsparser to parse the command-line arguments passed by the user.
Now the program had an option for the user to specify his/her choice of dateformat.

like,

program -d %d/%m/%Y-%H:%M:%S , program -d %d/%m/%Y and so on.

The problem I am facing is, *How do I check the validity of the format string passed by the user? *

The only way I can think of now is passing the format string on to the date class and using the exception handling there.

However, if there is another way to check the validity at the time of parsing the options then I wouldn’t need to pass around the data and do stuff unncessarily since I do some calculation before actually using the format to generate the date string.

  • 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-05-24T00:01:16+00:00Added an answer on May 24, 2026 at 12:01 am

    I wouldn’t need to pass around the data and do stuff unncessarily since I do some calculation before actually using the format to generate the date string.

    Instead of jumping through hoops to calculate something to pass to the date class to validate the format string, why don’t you just ask the date class to format today’s date for you and see if it generates an exception or not?

    If you try to parse it yourself you’re just writing code that’s duplicating what the date class does, but that also has the chance of missing some detail. You may annoy your user by disallowing something that should be allowed (I’ve had this happen with applications that tell me my perfectly valid email isn’t), and you’ll have to handle the exception from the date class anyway in case you don’t cover all the bases that it covers when parsing the format

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

Sidebar

Related Questions

Using boost.spirit I try to parse simple command line of the form command:param1 param2...
I'm using boost::program_options to read the users' input from the command line argument. It
I am using boost build in my project and now i want to use
I am using boost shared pointers in my program, and I have a class
Using boost::program_options, I can not get my own option type to compile when it
I am using boost::signal in a native C++ class, and I now I am
Using Boost Program Options, how do you get the string equivalent of argv[0]?
Using Boost.Python, is there a way to call a Python function that's been passed
I am using using boost libraries to parse a file. Its known that when
Using boost-bind , the resulting boost-function may receive more arguments than the bound object

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.