bmx-ng / pub.mod

BlitzMax NG Pub modules port.
7 stars 8 forks source link

Improvement of SDateTime to include now() functionality #70

Open Scaremonger opened 5 months ago

Scaremonger commented 5 months ago

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...