Faker C++
Loading...
Searching...
No Matches
date.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <string_view>
5
6#include "faker-cxx/export.h"
7
8namespace faker::date
9{
10enum class DateFormat
11{
12 ISO,
14};
15
29FAKER_CXX_EXPORT std::string anytime(DateFormat dateFormat = DateFormat::ISO);
30
46FAKER_CXX_EXPORT std::string pastDate(int years = 1, DateFormat dateFormat = DateFormat::ISO);
47
63FAKER_CXX_EXPORT std::string futureDate(int years = 1, DateFormat dateFormat = DateFormat::ISO);
64
80FAKER_CXX_EXPORT std::string recentDate(int days = 3, DateFormat dateFormat = DateFormat::ISO);
81
97FAKER_CXX_EXPORT std::string soonDate(int days = 3, DateFormat dateFormat = DateFormat::ISO);
98
115FAKER_CXX_EXPORT std::string birthdateByAge(int minAge = 18, int maxAge = 80, DateFormat dateFormat = DateFormat::ISO);
116
133FAKER_CXX_EXPORT std::string birthdateByYear(int minYear = 1920, int maxYear = 2000,
134 DateFormat dateFormat = DateFormat::ISO);
135
145FAKER_CXX_EXPORT std::string_view weekdayName();
146
156FAKER_CXX_EXPORT std::string_view weekdayAbbreviatedName();
157
167FAKER_CXX_EXPORT std::string_view monthName();
168
178FAKER_CXX_EXPORT std::string_view monthAbbreviatedName();
179
189FAKER_CXX_EXPORT unsigned year();
190
200FAKER_CXX_EXPORT unsigned month();
201
211FAKER_CXX_EXPORT unsigned hour();
212
222FAKER_CXX_EXPORT unsigned minute();
223
233FAKER_CXX_EXPORT unsigned second();
234
244FAKER_CXX_EXPORT std::string time();
245
255FAKER_CXX_EXPORT unsigned dayOfMonth();
256
266FAKER_CXX_EXPORT unsigned dayOfWeek();
267
277FAKER_CXX_EXPORT std::string_view timezoneRandom();
278
294FAKER_CXX_EXPORT std::string between(int64_t from, int64_t to, DateFormat dateFormat = DateFormat::ISO);
295
312FAKER_CXX_EXPORT std::string between(const std::string& from, const std::string& to, DateFormat dateFormat);
313}
Definition date.h:9
DateFormat
Definition date.h:11
FAKER_CXX_EXPORT unsigned hour()
Returns random hour.
FAKER_CXX_EXPORT std::string time()
Returns random time string.
FAKER_CXX_EXPORT std::string_view monthName()
Returns a random name of a month.
FAKER_CXX_EXPORT unsigned dayOfMonth()
Returns random day of month.
FAKER_CXX_EXPORT std::string recentDate(int days=3, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the recent past.
FAKER_CXX_EXPORT std::string_view timezoneRandom()
Returns random timezone.
FAKER_CXX_EXPORT std::string futureDate(int years=1, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the future.
FAKER_CXX_EXPORT std::string birthdateByYear(int minYear=1920, int maxYear=2000, DateFormat dateFormat=DateFormat::ISO)
Generates a random birthdate by year.
FAKER_CXX_EXPORT unsigned minute()
Returns random minute.
FAKER_CXX_EXPORT std::string anytime(DateFormat dateFormat=DateFormat::ISO)
Generates a random date between UNIX epoch and 200 years from now.
FAKER_CXX_EXPORT std::string soonDate(int days=3, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the soon future.
FAKER_CXX_EXPORT unsigned year()
Returns random year.
FAKER_CXX_EXPORT std::string between(int64_t from, int64_t to, DateFormat dateFormat=DateFormat::ISO)
Generates a random date between two given Unix timestamps.
FAKER_CXX_EXPORT unsigned dayOfWeek()
Returns random day of week.
FAKER_CXX_EXPORT std::string pastDate(int years=1, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the past.
FAKER_CXX_EXPORT std::string birthdateByAge(int minAge=18, int maxAge=80, DateFormat dateFormat=DateFormat::ISO)
Generates a random birthdate by age.
FAKER_CXX_EXPORT std::string_view weekdayName()
Returns a name of random day of the week.
FAKER_CXX_EXPORT unsigned second()
Returns random second.
FAKER_CXX_EXPORT unsigned month()
Returns random month.
FAKER_CXX_EXPORT std::string_view weekdayAbbreviatedName()
Returns an abbreviated name of random day of the week.
FAKER_CXX_EXPORT std::string_view monthAbbreviatedName()
Returns an abbreviated name of random month.