Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

operation: datetime: It return the date time in the required format. #1339

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gaurav879
Copy link

@gaurav879 gaurav879 commented Mar 18, 2022

fixes #1327 . The function return date and time in the required format (yyyy-mm-dd hh:mm)

@gaurav879 gaurav879 changed the title created 2 operators fixes issue #1327 Mar 21, 2022
@gaurav879 gaurav879 marked this pull request as ready for review March 21, 2022 08:00
@programmer290399
Copy link
Contributor

Hello @gaurav879 !!
Thanks for the PR, can you please take a look at the Git & GitHub section under the contribution docs and make the required changes to this PR's title and description.

@gaurav879 gaurav879 changed the title fixes issue #1327 operation: datetime: It return the date time in the required format. Mar 21, 2022
@gaurav879
Copy link
Author

@programmer290399 made the changes.



@op(name="dffml.datetime", outputs=current_datetime)
def date_time():
Copy link

@johnandersen777 johnandersen777 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def date_time():
def date_time_now() -> datetime.datetime:

date_time_format = str(
current_date + " " + current_time[0] + ":" + current_time[1]
)
return date_time_format

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



@op(name="dffml.datetimeformat", outputs=date_time)
def date_time_format():
Copy link

@johnandersen777 johnandersen777 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def date_time_format():
def date_time_format(datetime_obj: datetime.datetime, format: str) -> datetime.datetime:

return current_datetime


@op(name="dffml.datetimeformat", outputs=date_time)
Copy link

@johnandersen777 johnandersen777 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@op(name="dffml.datetimeformat", outputs=date_time)
@op(
name="dffml.datetimeformat",
inputs={
"datetime_obj": date_time,
"format": date_time,
},
outputs={
"str": date_time_str,
},
)

date_time = Definition(name="date_time", primitive="generic")


@op(name="dffml.datetime", outputs=current_datetime)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@op(name="dffml.datetime", outputs=current_datetime)
@op(
name="dffml.datetime.now",
outputs={
"date_time_obj": date_time,
},
)

from ..df.base import op
from ..df.types import Definition

current_datetime = Definition(name="current_datetime", primitive="generic")
Copy link

@johnandersen777 johnandersen777 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
current_datetime = Definition(name="current_datetime", primitive="generic")
date_time_str = Definition(name="date_time_str", primitive="string")
date_time_str_format = Definition(name="date_time_str_format", primitive="string", default="%Y-%m-%d %H:%M")

Current date and time.
"""
current_datetime = datetime.datetime.now()
return current_datetime

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return current_datetime
return {
"date_time_obj": current_datetime
}

Choose a reason for hiding this comment

The 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example doctest as unittest is dffml/source/dataset/iris.py, consider using type()

def date_time_format():
"""
A function to modify date and time format.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example here, pass in staticlly created datetime.datetime so that date is always the same

@programmer290399 programmer290399 added kind/operations Issues pertaining to Operations awaiting changes Reviewed and awaiting changes from author labels May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting changes Reviewed and awaiting changes from author kind/operations Issues pertaining to Operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

operations: datetime: Add operation to output current date
3 participants