Skip to content

Commit

Permalink
Merge pull request #21 from Hefaistos68/new-features-and-fixes
Browse files Browse the repository at this point in the history
New features and fixes
  • Loading branch information
Hefaistos68 authored Apr 19, 2023
2 parents f4430f2 + 1720477 commit 49fb224
Show file tree
Hide file tree
Showing 494 changed files with 10,767 additions and 5,499 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
# :date: MoreDateTime - [Github](https://github.com/Hefaistos68/MoreDateTime) / [Docs](https://hefaistos68.github.io/MoreDateTime/)


This library is built from the ground up to be a simple, easy to use, and intuitive date and time library for .NET, that simplifies common tasks and provides a consistent API for working with dates and times, throughout the DateTime, DateOnly and TimeOnly .NET objects. It adds many operations that one expects to find in a date and time library, but are missing from the .NET standard library.
This library is built from the ground up to be a simple, easy to use, and intuitive date and time library for .NET, that simplifies common tasks and provides a consistent API for working with dates and times, throughout the DateTime, DateOnly, TimeOnly and TimeSpan .NET objects. It adds many operations that one expects to find in a date and time library, but are missing from the .NET standard library. Currently it features over 300 methods to deal with dates and times and ranges (periods) thereof.

It is however not intended to be a replacement for any part of the standard .NET library, but rather an extension to it. It is built upon the existing .NET standard library and does not replace any of the existing functionality. It is also not intended to be a replacement for the [NodaTime](https://nodatime.org/) library, but it can be used in conjunction.

Conversions between the types or operations with mixed types (use DateTime and DateOnly for example without converting one into the other manually) are possible.

For example: `NextWeek()` to advance a DateTime or DateOnly to the same weekday in the next week, `NextYear()` to add a year to a DateTime or DateOlnly object (yes, of course you can use the existing `.AddYears(1)` method, but it does not look as clear), `NextWorkday()` to advance the DateTime or DateOnly object to the next working day on the given `Calendar`.

Expand Down Expand Up @@ -62,9 +66,13 @@ Just install the NuGet package and you are ready to go! It's mostly built upon c

### Dependencies

For Holiday calculations we use the [Nager.Date](https://github.com/nager/nager.date) library, but you need to bring your own license key. Optionally you can use your own provider through the `IHolidayProvider` interface.
For Holiday calculations it uses the [Nager.Date](https://github.com/nager/nager.date) library, but you need to bring your own license key. There is also a DefaultHolidayProvider() which knows only the very few international holidays and is the default. Optionally you can use your own provider through the `IHolidayProvider` interface and the `DateTimeProvider.SetHolidayProvider()` method.

### Note

Call `DateTimeExtensions.SetHolidayProvider()` to set your own provider. If you do not set a provider, the `NagerHolidayProvider` will be used, but you need to provide a valid license key.
[Documentation](https://hefaistos68.github.io/MoreDateTime/) is mostly complete, although there may be some missing or even wrong descriptions (copy paste errors usually). If you find something missing or wrong, please let me know.

Unit tests cover ~98%, a few edge cases are not covered yet. So there is a high confidence that the code is working correctly.

### Examples

Expand All @@ -79,9 +87,12 @@ PM> install-package MoreDateTime
<details>
<summary>Code Examples (click to expand)</summary>


## Examples for .NET (NuGet package)

### Do something simple with a date
_coming soon_

### Example 1 - tbd
```cs

--> code sample here, coming asap
Expand Down
279 changes: 119 additions & 160 deletions docs/MoreDateTime.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fti/FTI_100.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fti/FTI_101.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fti/FTI_102.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"field":[131074,262146,327682,393218,458754,589826,655362,1179650,5963778,6750210],"following":[1835009,4784129,6422529,13107201,23134209,24313857],"ffffff":[4784129,15728641,24313857],"false":[3407873,9437185,24641537],"firstsaturdayofmonth":[1835009,3997697,4784129,12517377,23134209,24313857],"fixed":[1638402],"falls":[1835010,4587521,4784130,5046273,11010049,23134210,23724033,24313858],"feb":[14090241,14286849],"firstweekdayofmonth":[1835009,4128769,4784129,11075585,23134209,24313857],"firstwednesdayofmonth":[1835009,3932161,4784129,10813441,23134209,24313857],"function":[3407873,9437185,24641537],"firsttuesdayofmonth":[1835009,3670017,4784129,9895937,23134209,24313857],"firstmondayofmonth":[1835009,3735553,4784129,12255233,23134209,24313857],"firstfridayofmonth":[1835009,4325377,4784129,9568257,23134209,24313857],"firstthursdayofmonth":[1835009,3866625,4784129,10092545,23134209,24313857],"fractions":[6356993,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7602177,7667713,7864321,13238273,13303809,13369345,13500417,13565953,13697025,13762561,13893633,13959169,14155777,14548993,14614529,15794177,16121857,16777217,16973825,17235969,25100289],"firstsundayofmonth":[1835009,3604481,4784129,9764865,23134209,24313857],"fields":[65539,196611,23134210,24313858],"forward":[1835009,3538945,23134209],"func":[1310721,1835009,3407875,4784129,9437187,18546689,18939905,19070977,21954561,23134209,24313857,24641539],"first":[1835024,2555905,2621441,2686977,2752513,2818049,2949121,3014659,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604484,3670020,3735556,3801089,3866628,3932164,3997700,4063233,4128771,4194306,4259842,4325380,4390913,4456450,4521986,4587521,4653058,4718594,4784139,4849666,4915202,4980738,5046273,5111809,5177345,5242881,5308417,5373953,5439490,5505026,5570561,5636098,5701634,5767169,5832706,5898241,6029313,6094850,6160385,6225921,6291457,6356993,6422529,6488065,6553602,6619137,6684675,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060931,8126465,8192001,8257537,8323073,8388611,8454145,8519681,8585217,8650753,8716290,8781825,8847361,8912897,9043969,8978433,9109505,9175041,9240577,9306113,9371649,9437185,9502721,9568260,9633795,9699329,9764868,9830401,9895940,9961473,10027010,10092548,10158081,10223618,10289153,10354690,10420226,10485762,10551298,10616834,10682370,10747905,10813444,10878978,10944514,11010049,11075588,11141121,11206658,11272194,11337729,11403265,11468801,11534337,11599873,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255236,12320769,12386305,12451841,12517380,12582913,12648449,12713985,12779521,12845057,12910593,13041665,12976129,13107201,13172738,13238273,13303809,13369345,13434882,13500417,13565953,13631489,13697025,13762561,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14745601,14811137,14876673,14942209,15007745,15073282,15138817,15204354,15269891,15335425,15400962,15466497,15532034,15597570,15663105,15728641,15794177,15859714,15925250,15990786,16056322,16121857,16187393,16252929,16318465,16384002,16449538,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17629185,17694721,17760257,17891329,17956865,18284545,18481153,18743298,18808833,22413313,22544386,22675458,22872066,23003137,23068674,23134224,23265281,23330818,23461889,23527426,23592961,23658497,23724033,23789569,23855105,23920641,23986177,24051713,24117249,24182785,24248321,24313867,24379393,24444929,24510466,24641537,24707074,24772609,24903681,24969217,25100289,25165825,25231361,25296897,25362433],"friday":[1835010,4325379,4784130,5111811,9568259,11796483,23134210,24313858],"follow":[2031617],"format":[1835009,4784129,9109506,15728642,23134209,24313857]}
{"format":[524289,786433,7798786,14811138,24707073,24772609],"firstmondayofmonth":[524289,786433,3604483,9895939,24707073,24772609],"function":[3342337,9502721,16187393],"fields":[65539,24707074],"firstthursdayofmonth":[524289,786433,3932163,10354691,24707073,24772609],"follow":[2031617],"falls":[524290,786434,4456449,5570561,10747905,13500417,24707074,24772610],"following":[524289,786433,6225921,17760257,24707073,24772609],"first":[524304,786443,2293761,2424833,2686977,2752513,2818049,2883585,2949121,3014659,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604484,3670017,3735556,3801092,3866628,3932164,3997700,4063236,4128771,4194305,4259842,4325378,4390914,4456449,4521986,4587522,4653058,4718594,4784130,4849666,4915202,4980738,5046274,5111810,5177346,5242882,5308417,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,5963778,6029313,6094849,6160385,6225921,6291457,6356993,6422531,6488065,6553601,6619137,6684673,6750209,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602179,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192003,8257537,8323073,8388609,8454146,8519682,8585217,8650753,8716289,8781825,8847363,8912897,8978433,9043969,9109505,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633796,9699332,9764865,9830404,9895940,9961476,10027010,10092546,10158081,10223618,10289154,10354692,10420225,10485762,10551298,10616834,10682369,10747905,10813442,10878978,10944514,11010050,11075586,11141122,11206657,11272193,11337729,11403266,11468802,11534338,11599873,11665409,11730945,11796481,11862018,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451844,12517377,12582913,12648449,12713985,12779521,12845057,12910593,12976129,13041666,13107201,13172737,13238273,13303812,13369345,13500417,13434881,13565953,13631489,13697025,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14876675,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15400961,15466497,15532034,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16252930,16318466,16384001,16449537,16515074,16580609,16646146,16711681,16777218,16842753,16908289,16973826,17039362,17104897,17170433,17235970,17301506,17367041,17432578,17498114,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219010,18284545,18350081,18415617,18481153,18546690,18612225,18677761,18743298,18808833,18874369,18939905,19005441,19070977,19136513,19202049,19267585,19333121,19398657,19464193,19529729,19726337,19922945,20185089,20971521,21233665,21561345,21757953,21889025,22020097,24707088,24772619],"feb":[13959169,16121857],"firstfridayofmonth":[524289,786433,3866627,9699331,24707073,24772609],"firstsaturdayofmonth":[524289,786433,3801091,9633795,24707073,24772609],"firsttuesdayofmonth":[524289,786433,4063235,12451843,24707073,24772609],"false":[3342337,9502721,16187393],"fractions":[6488065,6553601,6619137,6684673,6750209,6946817,7012353,7208961,7274497,7471105,7536641,7929857,8323073,8388609,12582913,12845057,12910593,12976129,13172737,13369345,13434881,13631489,13697025,13893633,14024705,14680065,15597569,16384001,16908289,17563649,21757953,22020097],"fixed":[1245186],"forward":[524289,3407873,24707073],"firstwednesdayofmonth":[524289,786433,3997699,13303811,24707073,24772609],"field":[1966082],"ffffff":[786433,14811137,24772609],"friday":[524290,786434,3866627,5439491,9699331,12713987,24707074,24772610],"firstweekdayofmonth":[524289,786433,4128771,9961475,24707073,24772609],"firstsundayofmonth":[524289,786433,3735555,9830403,24707073,24772609],"func":[458753,524289,786433,3342341,9502725,16187397,20578305,21626881,21692417,23592961,24707073,24772609]}
2 changes: 1 addition & 1 deletion docs/fti/FTI_103.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"globalization":[2097155,2162691,2293763,18612227,25034755],"going":[1835010,3538946,23134210],"goes":[1310721,1835009,3473409,4784129,9830401,15335425,18546689,18939905,19070977,21954561,23134209,24313857],"general":[1376258],"guide":[2555905,2621441,2686977,2752513,2818049,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604481,3670017,3735553,3801089,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4390913,4456449,4521985,4587521,4653057,4718593,4849665,4915201,4980737,5046273,5111809,5177345,5242881,5308417,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6029313,6094849,6160385,6225921,6291457,6356993,6422529,6488065,6553601,6619137,6684673,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8585217,8650753,8716289,8781825,8847361,8912897,9043969,8978433,9109505,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10747905,10682369,10813441,10878977,10944513,11010049,11075585,11141121,11206657,11272193,11337729,11403265,11468801,11534337,11599873,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12517377,12582913,12648449,12713985,12779521,12845057,12910593,13041665,12976129,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631489,13697025,13762561,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14745601,14811137,14876673,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15400961,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16252929,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17629185,17694721,17760257,17891329,17956865,18284545,18481153,18743297,18808833,22413313,22544385,22675457,22872065,23003137,23068673,23265281,23330817,23461889,23527425,23592961,23658497,23724033,23789569,23855105,23920641,23986177,24051713,24117249,24182785,24248321,24379393,24444929,24510465,24641537,24707073,24772609,24903681,24969217,25100289,25165825,25231361,25296897,25362433],"guess":[65537,131073,23134209],"given":[524290,720898,917506,983044,1245186,1310747,1835029,4128770,4194305,4390914,4587522,4784161,5046274,5177346,5242882,6029314,6422529,7733250,7798786,7929858,7995393,8192001,8257537,8519681,8650753,8716289,9502722,10158082,10420225,10682369,10747905,11010050,11075586,11141121,11206657,11272193,11337730,11403266,11468802,11534338,11927554,12582913,12779521,13107201,14090241,14286849,14417921,14483458,14745601,14811137,14942209,15138818,15204353,15400961,15859713,16056321,16187393,16384001,16449537,16515074,16580610,16908290,17104898,17432577,17498114,17956865,18743297,19005444,19136516,19267590,19333124,19464198,19595270,19726342,19922948,21364738,21954587,22085634,22216706,22282242,23003138,23134229,23265282,23396356,23461890,23658497,23724034,24248321,24313889,24903682,24969218,25559042,25624578],"gets":[851969,983041,1048577,1310731,1835022,2490369,4784154,6225921,6291457,6422529,6488065,6553601,6619137,6684673,7471105,7536641,7929857,7995393,8126465,8192001,8388609,11730945,11993089,12189697,12320769,12451841,12582913,12648449,12713985,12779521,12845057,12910593,12976129,13041665,13107201,13631489,13828097,14024705,14090241,14221313,14286849,14352385,14417921,14745601,14876673,14942209,15663105,16252929,16318465,16842753,17039361,17170433,17367041,17563649,17629185,17891329,18087937,19988481,20054018,20250626,20381698,20447233,20578308,20774913,20971521,21037057,21168129,21233665,21495809,21626881,21692417,21757955,21823489,21954571,22020097,22151169,22740995,22937604,23199747,23134222,23396353,23592961,23789569,23986177,24313882,25427969,25493505],"greater":[1310721,1835009,3473409,4390913,4784129,5177345,5242881,9830401,10158081,11337729,11403265,11468801,11534337,15335425,16580609,18546689,18939905,19070977,21954561,23134209,24313857,24903681,24969217]}
{"goes":[458753,524289,786433,3276801,9306113,15925249,20578305,21626881,21692417,23592961,24707073,24772609],"general":[2],"gets":[262145,393217,458763,524302,655361,786458,851969,917505,1638401,5963777,6094849,6160385,6225921,6291457,6356993,6422529,6815745,6881281,7077889,7143425,7340033,7405569,7602177,11665409,11796481,11927553,12058625,12255233,12517377,12648449,12779521,13107201,13238273,13565953,13959169,14155777,14221313,14286849,14352385,14417921,14548993,15138817,15400961,15728641,16121857,16580609,16711681,16842753,17104897,17170433,17760257,17956865,18153473,18350081,18677761,18808833,19005441,19202049,19464193,19529729,19791873,22282241,22544388,22675457,22872065,23068673,23134209,23199748,23265281,23330817,23461889,23592971,23658497,24379393,24510465,24641537,24707086,24772634],"globalization":[2228227,2359299,2490371,19660803,19857411],"guess":[65537,1966081,24707073],"guide":[2293761,2424833,2686977,2752513,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604481,3670017,3735553,3801089,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4390913,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4915201,4980737,5046273,5111809,5177345,5242881,5308417,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,5963777,6029313,6094849,6160385,6225921,6291457,6356993,6422529,6488065,6553601,6619137,6684673,6750209,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8585217,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9109505,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11141121,11206657,11272193,11337729,11403265,11468801,11534337,11599873,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12517377,12582913,12648449,12713985,12779521,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13500417,13434881,13565953,13631489,13697025,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14876673,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15400961,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16252929,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18481153,18546689,18612225,18677761,18743297,18808833,18874369,18939905,19005441,19070977,19136513,19202049,19267585,19333121,19398657,19464193,19529729,19726337,19922945,20185089,20971521,21233665,21561345,21757953,21889025,22020097],"greater":[458753,524289,786433,3276801,4194305,5308417,5373953,9306113,10158081,10420225,11206657,12124161,13828097,15925249,16449537,17629185,17891329,20578305,21626881,21692417,23592961,24707073,24772609],"given":[262146,393218,458779,524309,589826,655364,786465,851970,4128770,4194306,4259841,4456450,5308418,5373954,5570562,5898242,6225921,7077889,7143425,7340034,7667713,7733250,8060930,8126465,8257538,8519681,9175041,9961474,10027009,10092545,10158082,10420226,10682369,10747906,10813441,11075585,11206658,11599873,12124162,12320770,12517377,13500418,13828098,13959169,14090242,14221313,14352385,14548993,14614530,15007746,15073281,15269890,15532033,15794178,16121857,16252929,16318465,16449538,16646145,16777217,17367041,17498113,17629186,17694722,17760257,17825793,17891330,17956865,18219009,18415617,19070977,19398657,19726338,19922946,20971522,21168132,21299204,21364742,21430278,21495814,21823492,21954566,22085634,22151172,22413314,23134210,23461892,23592987,23658498,23724034,24510466,24707093,24772641],"going":[524290,3407874,24707074]}
Loading

0 comments on commit 49fb224

Please sign in to comment.