Terarea  2
The automation project
Loading...
Searching...
No Matches
src.lib.sql.sql_time_manipulation.SQLTimeManipulation Class Reference
Collaboration diagram for src.lib.sql.sql_time_manipulation.SQLTimeManipulation:
Collaboration graph

Public Member Functions

None __init__ (self, bool debug=False)
 
str datetime_to_string (self, datetime datetime_instance, bool date_only=False, bool sql_mode=False)
 
str string_to_datetime (self, str datetime_string_instance, bool date_only=False)
 
str get_correct_now_value (self)
 
str get_correct_current_date_value (self)
 

Data Fields

bool debug = debug
 
str date_only = SCONST.DATE_ONLY
 
str date_and_time = SCONST.DATE_AND_TIME
 
Disp disp
 

Detailed Description

_summary_

Definition at line 12 of file sql_time_manipulation.py.

Constructor & Destructor Documentation

◆ __init__()

None src.lib.sql.sql_time_manipulation.SQLTimeManipulation.__init__ ( self,
bool debug = False )
_summary_
    This is the class that contains functions in charge of manipulating time.
    It can convert time from as string to a datetime and vice-versa

Args:
    debug (bool, optional): _description_. Defaults to False.

Definition at line 16 of file sql_time_manipulation.py.

Member Function Documentation

◆ datetime_to_string()

str src.lib.sql.sql_time_manipulation.SQLTimeManipulation.datetime_to_string ( self,
datetime datetime_instance,
bool date_only = False,
bool sql_mode = False )
_summary_
    Convert a datetime instance to a string.

Args:
    datetime_instance (datetime): _description_: The datetime item
    date_only (bool, optional): _description_. Defaults to False.: if True will only return the date section, otherwise will return the date and time section.
    sql_mode (bool, optional): _description_. Defaults to False.: if True, will add the microseconds to the response so that it can be directly inserted into an sql command.

Raises:
    ValueError: _description_: If the datetime instance is not a datetime, a valueerror is raised.

Returns:
    str: _description_: A string instance of the datetime.

Definition at line 37 of file sql_time_manipulation.py.

◆ get_correct_current_date_value()

str src.lib.sql.sql_time_manipulation.SQLTimeManipulation.get_correct_current_date_value ( self)
_summary_
    Get the current date and time in the correct format for the database.

Returns:
    str: _description_

Definition at line 104 of file sql_time_manipulation.py.

◆ get_correct_now_value()

str src.lib.sql.sql_time_manipulation.SQLTimeManipulation.get_correct_now_value ( self)
_summary_
    Get the current date and time in the correct format for the database.

Returns:
    str: _description_

Definition at line 94 of file sql_time_manipulation.py.

◆ string_to_datetime()

str src.lib.sql.sql_time_manipulation.SQLTimeManipulation.string_to_datetime ( self,
str datetime_string_instance,
bool date_only = False )
_summary_
    Convert a datetime instance to a string.

Args:
    datetime_string_instance (str): _description_: The string datetime item
    date_only (bool, optional): _description_. Defaults to False.: if True will only return the date section, otherwise will return the date and time section.

Raises:
    ValueError: _description_: If the datetime instance is not a datetime, a valueerror is raised.

Returns:
    str: _description_: A string instance of the datetime.

Definition at line 69 of file sql_time_manipulation.py.

Field Documentation

◆ date_and_time

src.lib.sql.sql_time_manipulation.SQLTimeManipulation.date_and_time = SCONST.DATE_AND_TIME

Definition at line 27 of file sql_time_manipulation.py.

◆ date_only

src.lib.sql.sql_time_manipulation.SQLTimeManipulation.date_only = SCONST.DATE_ONLY

Definition at line 26 of file sql_time_manipulation.py.

◆ debug

bool src.lib.sql.sql_time_manipulation.SQLTimeManipulation.debug = debug

Definition at line 24 of file sql_time_manipulation.py.

◆ disp

Disp src.lib.sql.sql_time_manipulation.SQLTimeManipulation.disp
Initial value:
= Disp(
TOML_CONF,
SAVE_TO_FILE,
FILE_NAME,
debug=self.debug,
logger=self.__class__.__name__
)

Definition at line 29 of file sql_time_manipulation.py.


The documentation for this class was generated from the following file: