Skip to content

Commit

Permalink
Added ISO and Timestamp to Structure/Date tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-bodhi committed Dec 30, 2023
1 parent 9890629 commit 90a1527
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
20 changes: 13 additions & 7 deletions include/faker-cxx/Structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,19 @@ enum class Token
// Datatype module
DatatypeBoolean,

// Date module
DatePastDate,
DatefutureDate,
DateRecentDate,
DateSoonDate,
DateBirthdateByAge,
DateBirthdateByYear,
// Date module ISO and Timestamp
DatePastDateISO,
DatePastDateTimestamp,
DatefutureDateISO,
DatefutureDateTimestamp,
DateRecentDateISO,
DateRecentDateTimestamp,
DateSoonDateISO,
DateSoonDateTimestamp,
DateBirthdateByAgeISO,
DateBirthdateByAgeTimestamp,
DateBirthdateByYearISO,
DateBirthdateByYearTimestamp,
DateWeekdayName,
DateWeekdayAbbreviatedName,
DateMontName,
Expand Down
16 changes: 10 additions & 6 deletions src/modules/structure/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ const std::map<faker::Token, std::function<std::string()>> moduleFunctions = {

{faker::Token::DatatypeBoolean, []() { return std::to_string(faker::Datatype::boolean()); }},

{faker::Token::DatePastDate, []() { return faker::Date::pastDate(); }},
{faker::Token::DatefutureDate, []() { return faker::Date::futureDate(); }},
{faker::Token::DateRecentDate, []() { return faker::Date::recentDate(); }},
{faker::Token::DateSoonDate, []() { return faker::Date::soonDate(); }},
{faker::Token::DateBirthdateByAge, []() { return faker::Date::birthdateByAge(); }},
{faker::Token::DateBirthdateByYear, []() { return faker::Date::birthdateByYear(); }},
{faker::Token::DatePastDateISO, []() { return faker::Date::pastDate(); }},
{faker::Token::DatePastDateTimestamp, []() { return faker::Date::pastDate(1, faker::Date::DateFormat::Timestamp); }},
{faker::Token::DatefutureDateISO, []() { return faker::Date::futureDate(); }},
{faker::Token::DatefutureDateTimestamp, []() { return faker::Date::futureDate(1, faker::Date::DateFormat::Timestamp); }},
{faker::Token::DateRecentDateISO, []() { return faker::Date::recentDate(); }},
{faker::Token::DateRecentDateTimestamp, []() { return faker::Date::recentDate(3, faker::Date::DateFormat::Timestamp); }},
{faker::Token::DateSoonDateISO, []() { return faker::Date::soonDate(); }},
{faker::Token::DateSoonDateTimestamp, []() { return faker::Date::soonDate(3, faker::Date::DateFormat::Timestamp); }},
{faker::Token::DateBirthdateByAgeISO, []() { return faker::Date::birthdateByAge(); }},
{faker::Token::DateBirthdateByYearTimestamp, []() { return faker::Date::birthdateByYear(1920, 2000, faker::Date::DateFormat::Timestamp); }},
{faker::Token::DateWeekdayName, []() { return faker::Date::weekdayName(); }},
{faker::Token::DateWeekdayAbbreviatedName, []() { return faker::Date::weekdayAbbreviatedName(); }},
{faker::Token::DateMontName, []() { return faker::Date::monthName(); }},
Expand Down

0 comments on commit 90a1527

Please sign in to comment.