or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mdcore-providers.mddatetime.mdfinancial-data.mdindex.mdinternet-data.mdlocation-data.mdpersonal-data.mdschema.mdspecialized-providers.mdtext-content.md

datetime.mddocs/

0

# Date and Time Generation

1

2

Generate dates, times, timestamps, and time-related data with flexible date ranges, formatting options, and timezone support for testing temporal functionality.

3

4

## Capabilities

5

6

### Date Generation

7

8

```python { .api }

9

class Datetime(BaseDataProvider):

10

def date(self, start: int = 2000, end: int = 2023) -> datetime.date:

11

"""Generate a random date within specified year range."""

12

13

def formatted_date(self, fmt: str = "", **kwargs) -> str:

14

"""Generate formatted date string with custom format."""

15

16

def day_of_week(self, abbr: bool = False) -> str:

17

"""Generate day of week name or abbreviation."""

18

19

def day_of_month(self) -> int:

20

"""Generate day of month (1-31)."""

21

22

def month(self, abbr: bool = False) -> str:

23

"""Generate month name or abbreviation."""

24

25

def year(self, minimum: int = 1990, maximum: int = 2023) -> int:

26

"""Generate year within specified range."""

27

28

def century(self) -> str:

29

"""Generate century designation."""

30

```

31

32

### Time Generation

33

34

```python { .api }

35

class Datetime(BaseDataProvider):

36

def time(self) -> datetime.time:

37

"""Generate random time."""

38

39

def formatted_time(self, fmt: str = "") -> str:

40

"""Generate formatted time string."""

41

42

def datetime(self, start: int = 2000, end: int = 2023) -> datetime.datetime:

43

"""Generate random datetime within year range."""

44

45

def formatted_datetime(self, fmt: str = "", **kwargs) -> str:

46

"""Generate formatted datetime string."""

47

```

48

49

### Timezone and Temporal Data

50

51

```python { .api }

52

class Datetime(BaseDataProvider):

53

def timezone(self, region: TimezoneRegion = None) -> str:

54

"""Generate timezone identifier."""

55

56

def gmt_offset(self) -> str:

57

"""Generate GMT offset string like '+05:00'."""

58

59

def week_date(self, start: int = 2017, end: int = 2023) -> str:

60

"""Generate ISO week date."""

61

62

def periodicity(self) -> str:

63

"""Generate periodicity description."""

64

```

65

66

## Usage Examples

67

68

```python

69

from mimesis import Datetime

70

from mimesis.enums import TimezoneRegion

71

72

dt = Datetime()

73

74

# Basic date/time generation

75

random_date = dt.date(start=2020, end=2023)

76

random_time = dt.time()

77

random_datetime = dt.datetime()

78

79

# Formatted output

80

formatted_date = dt.formatted_date(fmt="%Y-%m-%d") # "2023-05-15"

81

formatted_time = dt.formatted_time(fmt="%H:%M:%S") # "14:30:25"

82

83

# Timezone information

84

timezone = dt.timezone(TimezoneRegion.EUROPE) # "Europe/London"

85

gmt_offset = dt.gmt_offset() # "+02:00"

86

```