Skip to content

Improvement of SDateTime to include now() functionality #70

@Scaremonger

Description

@Scaremonger

RE: pub.stdc / Struct SDateTime

When working with SDateTime you often need a now() method to get the current date & time. To get this you currently have to do this:

Local now:SDateTime
CurrentDateTime( now )

Please could you consider adding the "now" functionality into SDateTime either as a default constructor or as a method like this:

	Rem
	bbdoc: Create an object representing the current date and time
	returns: The current date and time
	End Rem
	Method Now:SDateTime( utc:Int = True )
		CurrentDateTime( self, utc )
		Return self
	End Method

We can then create a variable simply by doing this:

Local now:SDateTime = new SDateTime.now()

Having this as a function would also be useful and would sit alongside the existing CurrentDateTime() :

Rem
bbdoc: Create an object representing the current date and time
returns: The current date and time
End Rem
Function CurrentDateTime:SDateTime( utc:Int = True )
	Local dt:SDateTime
	CurrentDateTime( dt, utc )
	Return dt
End Function

We can then use it in this way:

Local now:SDateTime = CurrentDateTime()

Thanks in advance...
Si...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions