Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: dt_setdateseparator not working?

  1. #1

    dt_setdateseparator not working?

    When I use DT_SetDateSeparator("/"), dates returned from DT_SecToDate are returned with hyphens rather than the specified forward slash. Is this the expected behavior and, if so, what does DT_SetDateSeparator do?

    Thanks in advance.

    I am running version 1.6.0.0.

  2. #2

    Re: dt_setdateseparator not working?

    Hi fmaxwell

    You might find the following program useful it uses DT_SecToDate to display the current date & places a forward-slash between the different parts.

    [code=thinbasic]
    ' thinBASIC GUI file

    uses "DT"

    dim s as string

    s = dt_sectodate(dt_datetosec(""))

    msgbox 0, dt_dateformat(s, "yyyy/MM/dd")
    [/code]
    Operating System: Windows 10 Home 64-bit
    CPU: Intel Celeron N4000 CPU @ 1.10GHz
    Memory: 4.00GB RAM
    Graphics: Intel UHD Graphics 600

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: dt_setdateseparator not working?

    Ciao fmaxwell and welcome here.

    I will check asap your problem and give you back.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: dt_setdateseparator not working?

    fmaxwell,

    I made some quick check.
    dt_setdateseparator function set the date separator but that separator is used only when DT_DateFormat is executed without any format.
    For example in DT_DateFormat("06.04.2005", ""). In this case, because there is now format, the indicated separator is used.

    Can you please post a little example not working for you?
    It can help me whet's going wrong.

    Thanks
    Eros

    PS: DT module help is very bad. I need to rewrite it absolutely! Sorry.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5

    Re: dt_setdateseparator not working?

    ErosOlmi,

    The DT stuff is really quite good compared to what one finds in most languages. The primary problem I have had with it has to do with documentation. I needed to convert from one time format to another. The first, a ground station for satellites that runs a language called STOL (Satellite Test and Operations Language), stores time as the number of seconds since 1/1/1970 at 12AM. The other (Excel) stores time as a floating point number equal to 2 + number of days since 1/1/1900 (Excel reproduces Lotus 123 bugs that counted 1/1/1900 as a leap year {it was not} and started numbering at 1 instead of 0). In addition, I needed to be able to display and process the dates within thinBasic. It's all up and running and works beautifully, but I never did find an indication of what thinBasic's native time storage format is (number of seconds since what?).

    Here's a code snippet:

    [code=thinbasic]



    DT_SetDateSeparator("/")
    ...
    TBTime = ThisTlmLine(1) + DT_DateToSec("01/01/1970") ' Get timestamp and adjust for different time bases.
    TB_Datestring = DT_SecToDate(TBTime) ' Create ThinBasic datestamp


    [/code]

    What I expected to get out of there was a date in the format mm/dd/yyyy. Instead, I got one formatted as mm-dd-yyyy.

    It was easy enough to fix:

    [code=thinbasic]

    TBTime = ThisTlmLine(1) + DT_DateToSec("01-01-1970") ' Get timestamp and adjust for different time bases.
    TB_Datestring = DT_Dateformat (DT_SecToDate(TBTime), "MM/dd/yyyy" ) ' Create ThinBasic datestamp


    [/code]

    I'd really like to see the DT_SetDateSeparator function affect everything that accepts or produces a date. For example, the following should work:

    [code=thinbasic]

    DT_SetDateSeparator("@")
    '---Results "06@13@2005"
    MsgBox 0, DT_SecToDate(DT_DateToSec("06@13@05"))


    [/code]

    Note about documentation bug: Help file says that the format should be "Dd" for day of month as digits with leading zero for single-digit days., but it really is "dd." "Dd" will give you a day formatted with a letter D in front of it.

    If you do rewrite the DT function, PLEASE let it handle fractions of seconds. I would love to be able to get time as hh:mm:ss.sss, for example. Also, what about conversions, in and out, for common date and time storage formats, such as Unix and Excel? Maybe even create a function to specify a format (epoch, time unit, offset, data type -- example for Unix time format: epoch: 1/1/1970 00:00:00, units: seconds, offset: 0, data type: Long)

    P.S. I've been a software engineer since 1980. thinBasic is the first new language I've found in years that I've really been excited by. Thank you!

    Regards,
    Fred

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: dt_setdateseparator not working?

    Well,

    first thanks for your nice comment.

    Usually, when we create a module, we do not put much in there unless we really need it. What we do is to listen to other people using it and get feedback, suggestions, bug fixes. Now it seems you did a lot of work with thinBasic and DT module. Also your suggestions are very very interesting. I will discuss with Roberto (DT module creator) about this and give you back. Maybe time to re-think some code and how we implemented.

    Ciao
    Eros

    PS: I've created a new child forum dedicated to Dates and moved you original post here.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: dt_setdateseparator not working?

    Hi Fred,

    as Eros said until now the DT_SetDateSeparator() function sets the date separator used only by DT_DateFormat() but you are right, better to extend the use of it also into DT_SecToDate() function, sure I'll do that ASAP.
    Instead I don't know how handle fractions of seconds, I need to study, may be a solution could be using msec instead of seconds in all calculations but I'm not sure.
    Also I'll have to check Unix time format.

    regards,
    Roberto
    http://www.thinbasic.com

  8. #8

    Re: dt_setdateseparator not working?

    Fred,

    as request the DT_SecToDate() has been changed, you'll find this update in the next ThinBasic release.

    Bye,
    Roberto
    http://www.thinbasic.com

  9. #9

    Re: dt_setdateseparator not working?

    Quote Originally Posted by RobertoBianchi
    Fred,

    as request the DT_SecToDate() has been changed, you'll find this update in the next ThinBasic release.

    Bye,
    Roberto
    You guys are great! Thanks so much. If you get people whining because it breaks things, please feel free to send them to me and I'll flame them for you.

  10. #10

    Re: dt_setdateseparator not working?

    Fred,

    changed also the DT_TimeToSec() behavior in order to work with the DT_SetTimeSeparator().
    Added the DT_GetTime() function that returns time in the following format: hh:mm:ss.mmm, DT_TimeToMillisec() and DT_MillisecToTime() for work with it as show below:

    [code=thinbasic]uses "DT"

    DIM sTimeString as string
    DIM sTimeString1 as string
    dim nMillisecond as ext

    DT_SetDateSeparator("@")
    '---Results "06@13@2005"
    MsgBox 0, DT_SecToDate(DT_DateToSec("06@13@05"))

    sTimeString = DT_GetTime()

    MsgBox 0, sTimeString, %MB_OK, "Result of DT_GetTime()"

    nMillisecond = DT_TimeToMillisec(sTimeString)

    MsgBox 0, nMillisecond, %MB_OK, "Result of DT_TimeToMillisec()"

    sTimeString1 = DT_MillisecToTime(nMillisecond)

    MsgBox 0, sTimeString + $CRLF + sTimeString1, %MB_OK, "Result of DT_MillisecToTime()"
    [/code]

    Ciao,
    Roberto
    Attached Files Attached Files
    http://www.thinbasic.com

Page 1 of 2 12 LastLast

Similar Threads

  1. What are you working on?
    By Michael Clease in forum TBGL General
    Replies: 17
    Last Post: 02-02-2008, 07:11

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •