Faker C++
Loading...
Searching...
No Matches
date.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <string_view>
6
7#include "faker-cxx/export.h"
8
9namespace faker::date
10{
11enum class DateFormat
12{
15};
16
30FAKER_CXX_EXPORT std::string anytime(DateFormat dateFormat = DateFormat::ISO);
31
47FAKER_CXX_EXPORT std::string pastDate(unsigned int years = 1, DateFormat dateFormat = DateFormat::ISO);
48
64FAKER_CXX_EXPORT std::string futureDate(unsigned int years = 1, DateFormat dateFormat = DateFormat::ISO);
65
81FAKER_CXX_EXPORT std::string recentDate(unsigned int days = 3, DateFormat dateFormat = DateFormat::ISO);
82
98FAKER_CXX_EXPORT std::string soonDate(unsigned int days = 3, DateFormat dateFormat = DateFormat::ISO);
99
116FAKER_CXX_EXPORT std::string birthdateByAge(unsigned int minAge = 18, unsigned int maxAge = 80,
117 DateFormat dateFormat = DateFormat::ISO);
118
135FAKER_CXX_EXPORT std::string birthdateByYear(unsigned int minYear = 1920, unsigned int maxYear = 2000,
136 DateFormat dateFormat = DateFormat::ISO);
137
147FAKER_CXX_EXPORT std::string_view weekdayName();
148
158FAKER_CXX_EXPORT std::string_view weekdayAbbreviatedName();
159
169FAKER_CXX_EXPORT std::string_view monthName();
170
180FAKER_CXX_EXPORT std::string_view monthAbbreviatedName();
181
191FAKER_CXX_EXPORT unsigned year();
192
202FAKER_CXX_EXPORT unsigned month();
203
213FAKER_CXX_EXPORT unsigned hour();
214
224FAKER_CXX_EXPORT unsigned minute();
225
235FAKER_CXX_EXPORT unsigned second();
236
246FAKER_CXX_EXPORT std::string time();
247
257FAKER_CXX_EXPORT unsigned dayOfMonth();
258
268FAKER_CXX_EXPORT unsigned dayOfWeek();
269
279FAKER_CXX_EXPORT std::string_view timezoneRandom();
280
296FAKER_CXX_EXPORT std::string between(int64_t from, int64_t to, DateFormat dateFormat = DateFormat::ISO);
297
314FAKER_CXX_EXPORT std::string between(const std::string& from, const std::string& to, DateFormat dateFormat);
315}
Definition date.h:10
DateFormat
Definition date.h:12
@ ISO
Definition date.h:13
@ Timestamp
Definition date.h:14
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.