-
Notifications
You must be signed in to change notification settings - Fork 138
operation: datetime: It return the date time in the required format. #1339
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||||||||||||||||||||
import datetime | ||||||||||||||||||||||||
from ..df.base import op | ||||||||||||||||||||||||
from ..df.types import Definition | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
current_datetime = Definition(name="current_datetime", primitive="generic") | ||||||||||||||||||||||||
date_time = Definition(name="date_time", primitive="generic") | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
@op(name="dffml.datetime", outputs=current_datetime) | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
def date_time(): | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
A function to generate current date and time. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Parameters | ||||||||||||||||||||||||
---------- | ||||||||||||||||||||||||
output: | ||||||||||||||||||||||||
Current date and time. | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
current_datetime = datetime.datetime.now() | ||||||||||||||||||||||||
return current_datetime | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related discusion on if we fix #1350 then we don't need this suggestion (can be done after merging this PR, could change back after 1350 is addressed) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example doctest as unittest is dffml/source/dataset/iris.py, consider using |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
@op(name="dffml.datetimeformat", outputs=date_time) | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
def date_time_format(): | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
A function to modify date and time format. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example here, pass in staticlly created |
||||||||||||||||||||||||
Parameters | ||||||||||||||||||||||||
---------- | ||||||||||||||||||||||||
output: | ||||||||||||||||||||||||
Current date and time in yyyy-mm-dd hh:mm (24h)format. | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
currentDateTime = date_time() | ||||||||||||||||||||||||
current_date = str(currentDateTime).split(" ")[0] | ||||||||||||||||||||||||
current_time = str(currentDateTime).split(" ")[1].split(".")[0].split(":") | ||||||||||||||||||||||||
date_time_format = str( | ||||||||||||||||||||||||
current_date + " " + current_time[0] + ":" + current_time[1] | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
return date_time_format | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.