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{
14};
15
29FAKER_CXX_EXPORT std::string anytime(DateFormat dateFormat = DateFormat::ISO);
30
46FAKER_CXX_EXPORT std::string pastDate(unsigned int years = 1, DateFormat dateFormat = DateFormat::ISO);
47
63FAKER_CXX_EXPORT std::string futureDate(unsigned int years = 1, DateFormat dateFormat = DateFormat::ISO);
64
80FAKER_CXX_EXPORT std::string recentDate(unsigned int days = 3, DateFormat dateFormat = DateFormat::ISO);
81
97FAKER_CXX_EXPORT std::string soonDate(unsigned int days = 3, DateFormat dateFormat = DateFormat::ISO);
98
115FAKER_CXX_EXPORT std::string birthdateByAge(unsigned int minAge = 18, unsigned int maxAge = 80,
116 DateFormat dateFormat = DateFormat::ISO);
117
134FAKER_CXX_EXPORT std::string birthdateByYear(unsigned int minYear = 1920, unsigned int maxYear = 2000,
135 DateFormat dateFormat = DateFormat::ISO);
136
146FAKER_CXX_EXPORT std::string_view weekdayName();
147
157FAKER_CXX_EXPORT std::string_view weekdayAbbreviatedName();
158
168FAKER_CXX_EXPORT std::string_view monthName();
169
179FAKER_CXX_EXPORT std::string_view monthAbbreviatedName();
180
190FAKER_CXX_EXPORT unsigned year();
191
201FAKER_CXX_EXPORT unsigned month();
202
212FAKER_CXX_EXPORT unsigned hour();
213
223FAKER_CXX_EXPORT unsigned minute();
224
234FAKER_CXX_EXPORT unsigned second();
235
245FAKER_CXX_EXPORT std::string time();
246
256FAKER_CXX_EXPORT unsigned dayOfMonth();
257
267FAKER_CXX_EXPORT unsigned dayOfWeek();
268
278FAKER_CXX_EXPORT std::string_view timezoneRandom();
279
295FAKER_CXX_EXPORT std::string between(int64_t from, int64_t to, DateFormat dateFormat = DateFormat::ISO);
296
313FAKER_CXX_EXPORT std::string between(const std::string& from, const std::string& to, DateFormat dateFormat);
314}
Definition date.h:9
DateFormat
Definition date.h:11
@ ISO
Definition date.h:12
@ Timestamp
Definition date.h:13
FAKER_CXX_EXPORT unsigned hour()
Returns random hour.
FAKER_CXX_EXPORT std::string time()
Returns random time string.
FAKER_CXX_EXPORT std::string recentDate(unsigned int days=3, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the recent past.
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 birthdateByYear(unsigned int minYear=1920, unsigned int maxYear=2000, DateFormat dateFormat=DateFormat::ISO)
Generates a random birthdate by year.
FAKER_CXX_EXPORT std::string_view timezoneRandom()
Returns random timezone.
FAKER_CXX_EXPORT unsigned minute()
Returns random minute.
FAKER_CXX_EXPORT std::string futureDate(unsigned int years=1, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the future.
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 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_view weekdayName()
Returns a name of random day of the week.
FAKER_CXX_EXPORT unsigned second()
Returns random second.
FAKER_CXX_EXPORT std::string soonDate(unsigned int days=3, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the soon future.
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.
FAKER_CXX_EXPORT std::string pastDate(unsigned int years=1, DateFormat dateFormat=DateFormat::ISO)
Generates a random date in the past.
FAKER_CXX_EXPORT std::string birthdateByAge(unsigned int minAge=18, unsigned int maxAge=80, DateFormat dateFormat=DateFormat::ISO)
Generates a random birthdate by age.