Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2017-07-07 18:16:04 -04:00
parent 018dda723c
commit 8c3531f259

@@ -153,30 +153,30 @@ main()
``` ```
<a name="Localization_Demonstration"></a> <a name="Localization_Demonstration"></a>
### Localization Demonstration ### Localization Demonstration
```c++
#include "date.h"
#include <iomanip>
#include <iostream>
#include "date.h" // Define a series of char arrays for short and long name strings
#include <iomanip> // to be associated with German date output (US names will be
#include <iostream> // retrieved from the locale).
const char* const de_long_month_names[] =
// Define a series of char arrays for short and long name strings {
// to be associated with German date output (US names will be
// retrieved from the locale).
const char* const de_long_month_names[] =
{
"Januar", "Februar", "Marz", "April", "Mai", "Januar", "Februar", "Marz", "April", "Mai",
"Juni", "Juli", "August", "September", "Oktober", "Juni", "Juli", "August", "September", "Oktober",
"November", "Dezember", "NichtDerMonat" "November", "Dezember", "NichtDerMonat"
}; };
const char* const de_long_weekday_names[] = const char* const de_long_weekday_names[] =
{ {
"Sonntag", "Montag", "Dienstag", "Mittwoch", "Sonntag", "Montag", "Dienstag", "Mittwoch",
"Donnerstag", "Freitag", "Samstag" "Donnerstag", "Freitag", "Samstag"
}; };
int int
main() main()
{ {
using namespace date; using namespace date;
// create some gregorian objects to output // create some gregorian objects to output
@@ -194,17 +194,17 @@ main()
cout << static_cast<unsigned>(d1.month()) << '/' << d1.day() cout << static_cast<unsigned>(d1.month()) << '/' << d1.day()
<< '/' << d1.year() << '\n'; << '/' << d1.year() << '\n';
cout << d1.year() << '-' << d1.month() << '-' << d1.day() << '\n'; cout << d1.year() << '-' << d1.month() << '-' << d1.day() << '\n';
} }
```
If your OS supports the `std::locale("de_DE")` the above can be simplified to: If your OS supports the `std::locale("de_DE")` the above can be simplified to:
```c++
#include "date.h"
#include "tz.h"
#include <iostream>
#include "date.h" int
#include "tz.h" main()
#include <iostream> {
int
main()
{
using namespace date; using namespace date;
// create some gregorian objects to output // create some gregorian objects to output
@@ -217,8 +217,8 @@ If your OS supports the `std::locale("de_DE")` the above can be simplified to:
cout << format(loc, "%A\n", local_days{d1}); cout << format(loc, "%A\n", local_days{d1});
cout << format(loc, "%D\n", local_days{d1}); cout << format(loc, "%D\n", local_days{d1});
cout << format(loc, "%F\n", local_days{d1}); cout << format(loc, "%F\n", local_days{d1});
} }
```
<a name="Date_Period_Calculations"></a> <a name="Date_Period_Calculations"></a>
### Date Period Calculations ### Date Period Calculations