|
Forum Index : Microcontroller and PC projects : PicoMite format/language of DATE$ and DAY$
| Author | Message | ||||
| musterkonsument Newbie Joined: 10/02/2023 Location: GermanyPosts: 5 |
Is it posible to change the format of DATE$ from DD-MM-YYYY to DD.MM.YYYY and in DAY$ change the language of the names of the days? If not: @Peter , could you please implement this? I could not find something in the manual. Many thanks musterkonsument Hans-Werner |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8536 |
There is no DAY$. Only DATE$ and TIME$. You can handle DATE$ in a function: PRINT FUNCTION mydate$() FUNCTION mydate$() local m$ m$ = date$ mid$(m$,3,1) = "." mid$(m$,6,1) = "." mydate$ = m$ END FUNCTION Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2999 |
This works too. Function Date.DE$(d$) Date.DE$ = left$(d$,2)+"."+mid$(d$,4,2)+"."+right$(d$,4) end function > ? date.de$(date$) 12.02.2026 > A similar thing could be done with the DAYS$() function to use Select Case. The output of DAYS$() would choose the German equivalent. |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8536 |
ooh! I've never used DAY$... :) I do know that PRINT DAY$ only prints a null string though because I tried that. MMBasic itself has no language options though, only the keyboard language. It is also possible to have fonts with international characters in them. If you want, say, German day names then it will have to be handled in your program though. I doubt very much if it could be integrated into MMBasic. . Edited 2026-02-12 21:30 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4343 |
DELETED: wrong thread Edited 2026-02-12 21:24 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
| musterkonsument Newbie Joined: 10/02/2023 Location: GermanyPosts: 5 |
Thanks for your hints. Sorry, hat to write "Day$(date$). In manual V 6.02.00 page 185 there is the function DAY$(date$). Of corse i can write a user function, but it would be nice to replace the build in used names. @ phil99 , can not find a function named "DAYS$()". |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8536 |
The problem, I suspect, will be that the English names are string literals stored in the flash area of MMBasic. Changing language will almost certainly change the length of each name and therefore how it is looked up. I might be wrong - I'm only guessing. On top of that it would also be necessary to support all the other languages available via the keyboard too. This could mean quite a bit of work, probably changing the system to something like string arrays, and additional storage space (the latter probably isn't a problem). Only matherp can answer these questions. The very big advantage of using a user function is that it is relatively easy to modify for any current or future language without having to modify MMBasic again. It can be run from the Library to give fast execution yet take up no user program space. The function is DAY$(), by the way, not DAYS$(). I suspect Phil just had temporary finger problems. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2999 |
Just a typo. The quote from the manual below it is what I meant. Anyway here is the Function. Function Day.DE$(d$) Select Case Day$(d$) Case "Sunday" : Day.DE$ = "Sonntag" Case "Monday" : Day.DE$ = "Montag" Case "Tuesday" : Day.DE$ = "Dienstag" Case "Wednesday" : Day.DE$ = "Mittwoch" Case "Thursday" : Day.DE$ = "Donnerstag" Case "Friday" : Day.DE$ = "Freitag" Case "Saturday" : Day.DE$ = "Samstag" End Select End Function > ? day.de$(date$) Donnerstag > Edited 2026-02-12 22:15 by phil99 Footnote added 2026-02-13 08:57 by phil99 A shorter function name may be easier. Function Tag$(d$) Select Case Day$(d$) Case "Sunday" : Tag$ = "Sonntag" Case "Monday" : Tag$ = "Montag" Case "Tuesday" : Tag$ = "Dienstag" Case "Wednesday" : Tag$ = "Mittwoch" Case "Thursday" : TagE$ = "Donnerstag" Case "Friday" : Tag$ = "Freitag" Case "Saturday" : Tag$ = "Samstag" End Select End Function |
||||
| musterkonsument Newbie Joined: 10/02/2023 Location: GermanyPosts: 5 |
Of corse, the English names are in flash. I think, for instance, if a special named array with the name of days in other languages - wich the user has to define, begining say with sunday - this array will be used insted. I think this will be faster than a function? Edited 2026-02-12 22:20 by musterkonsument |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10946 |
Something that only changes once every 24 hours hardly seems to need a "faster" solution. Just store Phil's solution in the library and it is there whenever you need it. Edited 2026-02-12 22:36 by matherp |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8536 |
It's always going to be a case of how much is a particular function likely to be used vs how much time and effort would be needed to implement it. As far as I know no-one has asked for this before. It may be incredibly useful to one or two people yet never be used by anyone else. This is partly why the Library was implemented. You can add user SUBs and FUNCTIONs as you need them without needing any changes to MMBasic. Unless there is a need for speed there's not a lot of point in integrating anything that MMBasic can handle. You very rarely run DAY$() in a loop so any performance hit of using a SUB or FUNCTION is negligible. There are quite a few useful routines on Fruit of the Shed so stuff like this can be added there for others to use. There is a routine on there that uses DATE$ and returns a day$ that can be in any language you want. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| musterkonsument Newbie Joined: 10/02/2023 Location: GermanyPosts: 5 |
You all are right, i did not think far enough, so please forget my question. Thanks to all Hans-Werner |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8536 |
No problem :) After a while you get used to looking at things a little differently. Oh, and welcome to the forum. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| Merino Newbie Joined: 03/01/2026 Location: AustraliaPosts: 3 |
I’m migrating a data logging application to Webmite that uses EPOCH format for all timestamps, and now adding user friendly html table views of the information (such as pivoting by day-of-week and time of day, etc) with option of downloading corresponding CSV files. The Webmite with Struct/Types is fantastic for this. I’ve written Basic functions to byte-bash the output of the DATETIME function to extract individual fields and reformat the timestamps in different ways implement this, but realised these consume a lot of CPU cycles in a data intensive app like this – cycles and lines of code I’d prefer to keep for my app specific stuff. So, I was thinking it would be nice if DATETIME supported an optional argument that specified which parts of the epoch date and/or time to extract, and in what order and format – similar to the way the MMBASIC FORMAT function does for numbers using % format specifiers, but instead using a subset standard C/Python “strftime()” format specifiers e.g. DATETIME$(NOW,”%d %a %Y”) would return “13 Feb 2026” DATETIME$(NOW,”%Y.%m.%d”) would return “2026.02.13” DATETIME$(NOW,”%w”) would return day number of week (i.e "5") DATETIME$(NOW,”I%:%M %p” would return "10:58 AM" Mark F |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2999 |
A version of the German Tag$() function that accepts dates with "." as separators Function Tag$(d$) If Mid$(d$,3,1)="." Then d$=Left$(d$,2)+"-"+Mid$(d$,4,2)+"-"+Right$(d$,2) Select Case Day$(d$) Case "Sunday" : Tag$ = "Sonntag" Case "Monday" : Tag$ = "Montag" Case "Tuesday" : Tag$ = "Dienstag" Case "Wednesday" : Tag$ = "Mittwoch" Case "Thursday" : Tag$ = "Donnerstag" Case "Friday" : Tag$ = "Freitag" Case "Saturday" : Tag$ = "Samstag" End Select End Function Edited 2026-02-13 10:41 by phil99 |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3606 |
A 2-minute doodle for Gemini. DATETIME$ is a MMBasic function, so DATETM$ instead (though not using epoch--could no doubt be modified): ' Test Harness Dim NOW$ NOW$ = Date$ + " " + Time$ ' e.g., "13-02-2026 10:58:00" ' Test 1: Day MonthName Year ' Note: Standard strftime uses %b for Abbrev Month, not %a. Print DateTm$(NOW$, "%d %b %Y") ' -> 13 Feb 2026 ' Test 2: Sortable Date Print DateTm$(NOW$, "%Y.%m.%d") ' -> 2026.02.13 ' Test 3: Day of Week Number (0=Sun, 5=Fri, 6=Sat) Print DateTm$(NOW$, "%w") ' -> 5 ' Test 4: 12-Hour Time with AM/PM Print DateTm$(NOW$, "%I:%M %p") ' -> 10:58 AM End ' ------------------------------------------------------------- ' Function: DateTm$ ' Arguments: ' dt$ - Date string in format "dd-mm-yyyy hh:mm:ss" ' fmt$ - Format string (e.g. "%Y-%m-%d") ' ------------------------------------------------------------- Function DateTm$(dt$, fmt$) Local INTEGER d, m, y, h, n, s Local INTEGER i, w, h12 Local STRING ret$, tok$, ampm$ ' 1. Parse MMBasic Date/Time String ' Assumes "dd-mm-yyyy hh:mm:ss" d = Val(Left$(dt$, 2)) m = Val(Mid$(dt$, 4, 2)) y = Val(Mid$(dt$, 7, 4)) h = Val(Mid$(dt$, 12, 2)) n = Val(Mid$(dt$, 15, 2)) s = Val(Mid$(dt$, 18, 2)) ' 2. Calculate Weekday (Zellers Algorithm variation) ' w: 0=Sunday, ... 5=Friday, 6=Saturday Local INTEGER a_, y_, m_ a_ = (14 - m) \ 12 y_ = y - a_ m_ = m + 12 * a_ - 2 w = (d + y_ + y_ \ 4 - y_ \ 100 + y_ \ 400 + (31 * m_) \ 12) Mod 7 ' 3. Process Format String ret$ = "" For i = 1 To Len(fmt$) tok$ = Mid$(fmt$, i, 1) If tok$ <> "%" Then ret$ = ret$ + tok$ Else ' Move to specifier char i = i + 1 If i > Len(fmt$) Then Exit For tok$ = Mid$(fmt$, i, 1) Select Case tok$ ' --- Date Components --- Case "d": ret$ = ret$ + Format$(d, "%02g") ' Day (01-31) Case "m": ret$ = ret$ + Format$(m, "%02g") ' Month (01-12) Case "Y": ret$ = ret$ + Format$(y, "%04g") ' Year (2024) Case "y": ret$ = ret$ + Right$(Format$(y, "%04g"), 2) ' Year (24) ' --- Time Components --- Case "H": ret$ = ret$ + Format$(h, "%02g") ' Hour (00-23) Case "M": ret$ = ret$ + Format$(n, "%02g") ' Minute (00-59) Case "S": ret$ = ret$ + Format$(s, "%02g") ' Second (00-59) ' --- 12-Hour Logic --- Case "I": h12 = h Mod 12 If h12 = 0 Then h12 = 12 ret$ = ret$ + Format$(h12, "%02g") Case "p": If h >= 12 Then ret$ = ret$ + "PM" Else ret$ = ret$ + "AM" ' --- Names and Weekdays --- Case "w": ret$ = ret$ + Str$(w) ' Weekday Num (0-6) Case "a": ' Abbreviated Weekday (Sun, Mon...) ret$ = ret$ + Mid$("SunMonTueWedThuFriSat", w * 3 + 1, 3) Case "b": ' Abbreviated Month (Jan, Feb...) ret$ = ret$ + Mid$("JanFebMarAprMayJunJulAugSepOctNovDec", (m - 1) * 3 + 1, 3) ' --- Escape --- Case "%": ret$ = ret$ + "%" Case Else: ret$ = ret$ + "%" + tok$ ' Keep unknown tags End Select EndIf Next i DateTm$ = ret$ End Function ~ Edited 2026-02-13 11:29 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |