Timestamp¶
This documentation provides details about the data that can be faked for a timestamp.
To retrieve generated/fake data for a timestamp see the following capabilities:
from socfaker import SocFaker
sc = SocFaker()
print(sc.timestamp.in_the_past())
print(sc.timestamp.in_the_future())
print(sc.timestamp.current)
print(sc.timestamp.date_string())
Timestamp Class¶
-
class
socfaker.timestamp.
Timestamp
¶ The Timestamp Class provides methods to generate timestamps
-
current
¶ The current timestamp
- Returns:
- str: Returns the current timestamp in ISO 8601 format
-
date_string
(years=69, months=5, days=159)¶ Returns a date string
- Args:
- years ([type], optional): The number of years subtracted from the current time. Defaults to random.randint(18,85). months ([type], optional): The number of months subtracted from the current time. Defaults to random.randint(1,12). days ([type], optional): The number of days subtracted from the current time. Defaults to random.randint(1,365).
- Returns:
- str: An date string for the generated timestamp
-
in_the_future
(years=0, months=3, days=8, hours=1, minutes=45, seconds=28)¶ Generates a timestamp in the future
- Args:
- years (int, optional): The number of years to add from the current time. Defaults to 0. months ([type], optional): The number of months to add from the current time. Defaults to random.randint(0,3). days ([type], optional): The number of days to add from the current time. Defaults to random.randint(1,15). hours ([type], optional): The number of hours to add from the current time. Defaults to random.randint(1,24). minutes ([type], optional): The number of minutes to add from the current time. Defaults to random.randint(1,60). seconds ([type], optional): The number of seconds to add from the current time. Defaults to random.randint(1,60).
- Returns:
- str: Returns an ISO 8601 timestamp string
-
in_the_past
(years=0, months=0, days=9, hours=4, minutes=32, seconds=52)¶ Generates a timestamp in the past
- Args:
- years (int, optional): The number of years to subtract from the current time. Defaults to 0. months ([type], optional): The number of months to subtract from the current time. Defaults to random.randint(0,3). days ([type], optional): The number of days to subtract from the current time. Defaults to random.randint(1,15). hours ([type], optional): The number of hours to subtract from the current time. Defaults to random.randint(1,24). minutes ([type], optional): The number of minutes to subtract from the current time. Defaults to random.randint(1,60). seconds ([type], optional): The number of seconds to subtract from the current time. Defaults to random.randint(1,60).
- Returns:
- str: Returns an ISO 8601 timestamp string
-
in_the_past_pendulum_object
(years=0, months=0, days=8, hours=4, minutes=52, seconds=44)¶
-