0

I am using a function which is present in a library which I cannot modify. That function is used to set the Date by the user. Its parameters are

SetDate(sbyte day, sbyte month, sbyte year)

When I assign 2019. I want to assign 2019 to sbyte year. But the maximum value of sbyte is 127. I cannot use the last two digits of the year. As this function is taking all four digits as year. Could you please help me out how I should tackle this problem. I have to use this function. There is no other option to write any extension method.

Jay Buckman
  • 581
  • 5
  • 18
chaudhry
  • 21
  • 8
  • You cannot use the **first** two digits of the year. You will have to enter `19` for the year. Probably the century will be assumed to be the current century. – Olivier Jacot-Descombes Jun 26 '19 at 17:41
  • Thanks. I will try to do this way. – chaudhry Jun 26 '19 at 17:46
  • 3
    Welcome to Stack Overflow. Unfortunately, your question isn't clear at the moment. *Why* can you not use the last two digits of the year? What happens when you do? What is this method meant to achieve? Please give a lot more context. (Aside from anything else, it's bizarre that the parameters are `sbyte` rather than `byte`. It's weird that 2019 isn't a valid year value, but -10 would be...) – Jon Skeet Jun 26 '19 at 17:54
  • Yay, y2k bugs... never had those before /smh – Matthew Whited Jun 26 '19 at 17:57
  • 3
    It's also possible that it wants a "year from 1970" or "year from 1900" - both of which are still pretty flawed. Aside from anything else, I'd treat this as a warning siren that the library you're using should probably be abandoned as soon as you can - which may take a lot of work, so it's worth starting to look for an alternative ASAP. – Jon Skeet Jun 26 '19 at 17:58
  • Which library are you using? – Olivier Jacot-Descombes Jun 26 '19 at 18:04

0 Answers0