{"id":33145530,"url":"https://github.com/bsiever/microbit-pxt-timeanddate","last_synced_at":"2026-03-12T01:36:26.021Z","repository":{"id":42202568,"uuid":"270458189","full_name":"bsiever/microbit-pxt-timeanddate","owner":"bsiever","description":"Software Based Real Time Clock (Time \u0026 Date) for the Micro:Bit","archived":false,"fork":false,"pushed_at":"2022-09-05T16:04:09.000Z","size":217,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T16:36:53.186Z","etag":null,"topics":["makecode","microbit","pxt-microbit"],"latest_commit_sha":null,"homepage":"https://bsiever.github.io/microbit-pxt-timeanddate/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsiever.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"bsiever"}},"created_at":"2020-06-07T23:10:24.000Z","updated_at":"2022-11-22T05:51:14.000Z","dependencies_parsed_at":"2022-08-12T09:11:21.039Z","dependency_job_id":null,"html_url":"https://github.com/bsiever/microbit-pxt-timeanddate","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/bsiever/microbit-pxt-timeanddate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fmicrobit-pxt-timeanddate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fmicrobit-pxt-timeanddate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fmicrobit-pxt-timeanddate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fmicrobit-pxt-timeanddate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsiever","download_url":"https://codeload.github.com/bsiever/microbit-pxt-timeanddate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fmicrobit-pxt-timeanddate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30412088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T00:40:14.898Z","status":"ssl_error","status_checked_at":"2026-03-12T00:40:08.439Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["makecode","microbit","pxt-microbit"],"created_at":"2025-11-15T13:00:33.625Z","updated_at":"2026-03-12T01:36:26.013Z","avatar_url":"https://github.com/bsiever.png","language":"TypeScript","funding_links":["https://github.com/sponsors/bsiever"],"categories":["🗿 JavaScript and MakeCode"],"sub_categories":["🗿 MakeCode Extensions"],"readme":"# time-and-date\n\n```package\nmicrobit-pxt-timeanddate=github:bsiever/microbit-pxt-timeanddate\n```\n\nThis extension allows the micro:bit to keep track of the time and date.  It can also be used for primitive [stopwatch](#stopwatch-behavior)-like capabilities.\n\nIt's importantant to be aware that:\n- This extension uses a counter with differing accuracy on the v1 and v2 micro:bits:\n  - The v1 stability is about 10 parts per million, which is approximately 0.864 seconds per day and \n  - The v2 stability is 50 parts per million, which is about 4.32 seconds per day.  \n- The accuracy may change based on the environment (heat/cold) and from micro:bit to micro:bit.\n- If accuracy is important, you can use the stopwatch experiment described [below](#measuring-accuracy-and-calibrating) to estimate the accuracy of your micro:bit where you plan to use it.\n- The time needs to be set each time the micro:bit is reprogrammed or restarts.  \n\n# Compatability\n\n- Bluetooth is not currently supported on v1 (it is on v2)\n- Some v2 features, like low power mode or playing a melody continuously, may interfer with time keeping.\n\n\n## Setting the Time #setting-the-time\n\nThere are three common approaches to setting the time:\n\n1. [Synchronize at startup](#1-synchronize-at-startup) (easiest, but requires updating the program)\n2. [Time advancing / rewinding](#2-time-advancing-rewinding)\n3. [Digits count up / count down](#3-digits-count-up-count-down)\n\nUsing a reasonable \"startup value\", as described in [Synchronize at startup](#1-synchronize-at-startup), will make the last two approaches easier.\n\n### 1. Synchronize at startup #1-synchronize-at-startup\n\nSynchronizing the time at startup is the easiest approach, but it requires re-programming the micro:bit every time the time needs to be set, like whenever it is restarted.  The start up process just needs to include setting the time, like:\n\n```block\ntimeanddate.setDate(1, 20, 2022)\ntimeanddate.set24HourTime(13, 30, 0)\n```\n\n### ~hint\n\n#### Date is Optional!\n\nIf you just care about time and not the date, you don't have to set the date.\n\n### ~\n\nOnce you're ready to program the micro:bit:\n1. Update the time/date being used so the time is approximately 1 minute in the future.\n2. Program the micro:bit.\n3. Watch the real time carefully.\n4. About 1-2 seconds before the programmed time, press the reset button on the back of the micro:bit.\n   * The micro:bit takes about 1-2 seconds to restart. This causes the \"set\" block to run at the correct time.\n   \nFor the example above, the micro:bit would be reset at 13:29.58s on Jan. 20, 2022.  It would set the date and time at almost exactly the time indicated in the set block.\n\n### 2. Time advancing / rewinding #2-time-advancing-rewinding\n\nThis is the approach used by mechanical clocks, where time is set by moving the minute hand forward (or, possibly, backwards). Moving the minutes forward may cause the hours to change too. And as hours change the date could change, etc.\n\nThis is  a tedious way to set dates and should probably only be used when the date will never be needed and just the time needs to be set.\n\n#### 2.1 Simplest Approach\n\nHere's the simplest approach, where the buttons are dedicated to setting the time :\n\n```block\ninput.onButtonPressed(Button.A, function () {\n    timeanddate.advanceBy(1, timeanddate.TimeUnit.Minutes)\n})\n\ninput.onButtonPressed(Button.B, function () {\n    timeanddate.advanceBy(-1, timeanddate.TimeUnit.Minutes)\n})\n```\n\nThe buttons change the time one minute at a time (forward or backward).  Advancing the minutes beyond 59 or before 0 will cause the hour to change.\n\n#### 2.2 Alternate Approach: Setting at startup\n\nHere's an alternate approach that can be used to set the time at startup by advancing hours and minutes.  \n1. Hold \"A\" until the correct hour is shown.\n2. Hold \"B\" until the message says \"min:\".\n3. Hold \"A\" until the correct minute is shown.  \n4. Hold \"B\" again.\n\n```blocks\ninput.onButtonPressed(Button.A, function () {\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMM))\n})\nbasic.showString(\"hr:\")\nwhile (!(input.buttonIsPressed(Button.B))) {\n    if (input.buttonIsPressed(Button.A)) {\n        timeanddate.advanceBy(1, timeanddate.TimeUnit.Hours)\n    }\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMM))\n}\nbasic.showString(\"min:\")\nwhile (!(input.buttonIsPressed(Button.B))) {\n    if (input.buttonIsPressed(Button.A)) {\n        timeanddate.advanceBy(1, timeanddate.TimeUnit.Minutes)\n    }\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMM))\n}\n```\n\nIf setting the date this way it's best to use the ``[timeanddate.setDate()]`` to select a year near the current year.\n\n**This may not work correctly when the total time is before the year specified in ``[timeanddate.setDate()]``.   That is, if ``[timeanddate.setDate(1, 20, 2024)]`` specifies 2024, then negative values should not \"rollback\" before Jan 1, 2024.**\n\n### 3. Digits count up / count down #3-digits-count-up-count-down\n\nThis approach should be done on each digits of the time (minutes, hours, and if the date is important too, day, month, and year).  \n\n#### 3.1 Simplest Approach Example\n\nHere's an example that focuses on just the minutes (additional code is needed for hours, etc.):\n\n```block\ninput.onButtonPressed(Button.B, function () {\n    timeanddate.numericTime(function (hour, minute, second,  month, day, year) {\n        timeanddate.set24HourTime(hour, minute + -1, second)\n    })\n})\n\ninput.onButtonPressed(Button.A, function () {\n    timeanddate.numericTime(function (hour, minute, second,  month, day, year) {\n        timeanddate.set24HourTime(hour, minute + 1, second)\n    })\n})\n```\n\nSince the time setting commands use modular arithmetic, adding and subtracting to the prior value will \"rollover\" in the expected way and will not impact the hours, like the advancing approach would.\n\n#### 3.2 Alternate Approach: Setting Hour/Minute at Start\n\nThe following can be used to set the time at startup.  It will scroll the time continuously until you are done setting it.  \n\n1. Set the Hour by holding \"A\" to advance it or \"B\" to decrease it.\n2. Hold \"A+B\" until it says \"Set Min\".\n3. Then repeat the process for the minute.  \n4. When done hold \"A+B\" until the message stops scrolling.  \n\nOnce the time has been set the additional code that displays the time when \"A\" is pressed.\n\n```block\ninput.onButtonPressed(Button.A, function () {\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMMAMPM))\n})\ntimeanddate.setTime(11, 30, 0, timeanddate.MornNight.AM)\nbasic.showString(\"Set Hour\")\nwhile (!(input.buttonIsPressed(Button.AB))) {\n    timeanddate.numericTime(function (hour, minute, second, month, day, year) {\n        if (input.buttonIsPressed(Button.A)) {\n            timeanddate.set24HourTime(hour + 1, minute, 0)\n        } else if (input.buttonIsPressed(Button.B)) {\n            timeanddate.set24HourTime(hour - 1, minute, 0)\n        }\n    })\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMMAMPM))\n}\nbasic.showString(\"Set Min\")\nwhile (!(input.buttonIsPressed(Button.AB))) {\n    timeanddate.numericTime(function (hour, minute, second, month, day,  year) {\n        if (input.buttonIsPressed(Button.A)) {\n            timeanddate.set24HourTime(hour, minute + 1, 0)\n        } else if (input.buttonIsPressed(Button.B)) {\n            timeanddate.set24HourTime(hour, minute - 1, 0)\n        }\n    })\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMMAMPM))\n}\n```\n\n# Full API\n\n## Setting Time Using 24-hour Format #timeanddate-set24hourtime\n\nUse `[timeanddate.set24HourTime()]` to set the time using 24-hour format (hours from 0-23, minutes from 0-59, seconds from 0-59). See [Setting the Time](#setting-the-time).\n\n## Setting Time Using AM/PM Format #timeanddate-settime\n\nUse `[timeanddate.setTime()]` to set the time using am/pm format (hours from 1-12, minutes from 0-59, seconds from 0-59).  See [Setting the Time](#setting-the-time).\n\n## Setting the Date #timeanddate-setdate\n\nUse `[timeanddate.setDate()]` to set the date (month from 1-12, day from 1-31, year from 0000-9999). See [Setting the Time](#setting-the-time).\n\n## Getting the Time (string) #timeanddate-time\n\n```sig\ntimeanddate.time(timeanddate.TimeFormat.HMM)\n```\n\nProvides the current time in the selected format. \n\nIf no time has been set, the time will be based on when the micro:bit started (was reset).  By default time starts at 00:00.00 on 0000-01-01.\n\n\n## Getting the Date (string) #timeanddate-date\n\n```sig\ntimeanddate.date(timeanddate.DateFormat.MD)\n``` \n\nProvides the current date in the specified format. \n\nIf no date is set, it will start at 0000-01-01 when the micro:bit starts. \n\n### ~alert\n\n# Avoid using separate time and date if making a log of events\n\nRetrieving the time and date separately can cause problems.  For example, if the date is accessed at 23:59.59 and then time is then accessed, the time may have changed to 00:00.00 (the following day) and the date won't be correct for the time.\n\nUse the timestamp  or the ``[timeanddate.numericTime()]`` block to get numeric values for the date. \n\n### ~\n\n## Timestamps (string) #timeanddate-datetime\n\nOften a \"timestamp\" is needed to record events, like when measurements are taken for a science experiment.  Use:\n\n```sig \ntimeanddate.dateTime()\n``` \n\nIt provides the date and time in the format: YYYY-MM-DD HH:MM.SS.  This format can easily be \"sorted\" in spreadsheets.  This ensures that the date and time are retrieved at the same time (accessing them separately may lead to a date after the time if the the time is checked at almost exactly the end of\n the day).  See [Setting the Time](#setting-the-time).\n\n### ~hint\n\n#### When to use Timestamps\nUse timestamps when logging events that happen over multiple days  (more than 24 hours).   For example, an experiment recoding temperature every 10 minutes for a week should use timestamps.\n\n### ~\n\n## Accessing numeric values of time / date #timeanddate-numerictime\n \nNumeric values of time/date can be useful for things like alarm clocks.  Use:\n\n```sig\ntimeanddate.numericTime(function (hour, minute, second, month, day, year) {\n})\n```\n\n- Hour will be 0-23 (in 24-hour format)\n- Minute will be 0-59\n- Second will be 0-59.\n- Day will be 1-31\n- Month will be 1-12\n- Year is the year 0-65535\n\n### ~tip\n\n#### Numeric Time vs. separate hour, minute, second\n\nThe ``[timeanddate.numericTime()]``  avoids errors that can occur if separate things had been used to get each part of the time.  For example, if one block provided the current time of day\nand another block provided the date, it would be possible to access the time at 23:59.59 on 2020-01-01 and then the date a fraction of time later, \nwhen it had changed to 2020-01-02.  The combined date and time would appear to be 23:59.59 on 2020-01-02 even though the 23:59.59 was actually on 2020-01-01.\n\n### ~\n\n## Advancing and Adjusting Time #timeanddate-advanceby \n\n```sig\ntimeanddate.advanceBy(amount: number, unit: TimeUnit)\n``` \n\nCan be used to advance or set back the current time. It works by adding time to the current time in the given units, *with carries*.  Adding \nto minutes may cause an overflow and change the hours.  Negative amounts can be used to set the clock backwards, however the clock \ncan not be set back before the beginning of the year originally used to set the date (or year 0 if the date wasn't set).\n\nIt behaves like a mechanical clock: Advancing the minutes causes the hour to advance as well.  It may be useful \nfor adjusting the clocks accuracy (adding seconds occasionally if it's slow) or adjusting \nfor changes in timezone or daylight savings time.\n\n## Seconds the Micro:bit has been running #timeanddate-secondssincereset\n\n```sig\ntimeanddate.secondsSinceReset()\n```\n\nReports the time (in seconds) since the micro:bit started.\n\n## Minute Changing #timeanddate-onminutechanged\n\n```sig \ntimeanddate.onMinuteChanged(handler: () =\u003e void)\n```\nThe provided code will run when the minute changes. \n\n\n## Hour Changing #timeanddate-onhourchanged\n\n```sig\ntimeanddate.onHourChanged(handler: () =\u003e void)\n```\n\nThe provided code will run when the hour changes. \n\n\n## Day Changing #timeanddate-ondaychanged\n\n```sig\ntimeanddate.onDayChanged(handler: () =\u003e void)\n```\n\nThe provided code will run when the day changes. \n\n\n## Weekdays #timeanddate-datetodayofweek\n\nOnce you have the day, month, and year, you can use them on the:\n```sig\ntimeanddate.dateToDayOfWeek()\n```\n\nto determine the day of the week.  It returns a numeric code, where 0 is Monday, 1 is Tuesday, etc.\n\n## Day of the Year #timeanddate-datetodayofyear\n\nOnce you have the day, month, and year, you can use them on the:\n```sig\ntimeanddate.dateToDayOfYear()\n```\nto determine the ordinal day of the year.  1 is Jan. 1, 2, is Jan 2, etc.  Dec. 31 is either 365 or 366 (in a leap year).\n\n\n# Measuring Accuracy and Calibrating #measuring-accuracy-and-calibrating\n\nAccuracy can be estimated by comparing your micro:bit to an actual, accurate stopwatch.  \n\nUse the following program, which will start the time at 00:00.00 (just like a stop watch). \n\n```block\ninput.onButtonPressed(Button.A, function () {\n    basic.showString(timeanddate.dateTime())\n})\ninput.onButtonPressed(Button.B, function () {\n    basic.clearScreen()\n})\nbasic.showIcon(IconNames.Heart)\ntimeanddate.set24HourTime(0, 0, 0)\n```\n\nUse a stopwatch or stopwatch app on a computer/phone. To start measurement:\n1. To estimate the accuracy of the micro:bit you'll need to compare it's estimate of time to the stopwatch for a few hours (or even days). Be sure that it's set up someplace where it will have power continuously, either via battery or a USB cable,  for a long time (hours or days). Some computers will suspend power to USB devices if the computer isn't in use for a while, so you may want to use a USB  charger.\n   * The micro:bit's accuracy can be impacted by large changes in temperature.  It's best to test it in an environment that you'll be using it in.  That is, if it'll be left outside in cold weather, test the accuracy in similar conditions. \n2. Prepare to start the stopwatch\n3. Reset the micro:bit\n4. As soon as you see the heart on the micro:bit start the stopwatch \n\nThe micro:bit should be accurate to within about 1 second per day or better.  This experiment depends on your reaction time, which is probably about 0-2 seconds.  Consequently you may need to let it run for several days to estimate the accuracy. \n\nTo estimate the accuracy:\n1. Look at the stopwatch.  Pick a precise instant that you'll take the measurement and keep it in mind.  For example, if the  stop watch reads 2:13.20 you may decide to make the measurement at 2:14.00.\n2. At that precise instant press the \"A\" button.  The micro:bit will scroll it's current record of the time.  Compare it to the expected time.  For example, if the microbit indicated 0000-01-01 02:13.22 you'd estimate that the microbit  is about 2 seconds ahead. Since it's been running for 134 minutes, you'd estimate that it's gaining 2/134 seconds/minute. Since there are 1440 minutes in a day, this works out to about 21.5 seconds per day.\n\n### ~tip\n\n#### Improving Accuracy\nIf you measure the accuracy and it's consistent/predictable, you may be able to use the ``[timeanddate.advanceBy()]`` and ``[timeanddate.onHourChanged()]`` blocks to periodically adjust the accuracy.  \n \n**Be careful setting time backward while using ``[timeanddate.onHourChanged()]``!** It's possible to get stuck in a \"loop\" that continually resets the time. You may need to use a variable to identify which \"hour\" was the last one to be adjusted. \n\n### ~\n\n# Stopwatch behavior #stopwatch-behavior\n\nBy use of setting time to 0:0.0 this can be used as a simple stopwatch.  For example, for timing things that are less than 24 hours:\n\n```block\ninput.onButtonPressed(Button.A, function () {\n    timeanddate.set24HourTime(0, 0, 0)\n})\ninput.onButtonPressed(Button.B, function () {\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HHMMSS24hr))\n})\ntimeanddate.set24HourTime(0, 0, 0)\n```\n\n\"A\" starts counting and \"B\" shows the time elapsed since \"A\" was pressed (or the start)\n\n\n# Challenges!!!\n\n1. Find new ways to set the time or date.  \n2. Create an alarm clock! (Hint: Use ``[timeanddate.numericTime()]``)\n   * Start with a simple alarm that is pre-programmed. For example, the alarm will go off at 3pm each day.  The ``[timeanddate.numericTime()]`` uses 24-hour format time, so 3pm is 15:00. \n3. Add a snooze feature to your alarm clock!\n4. Create an adjustable alarm clork that allows the alarm time to be changed by using buttons or actions (rather than reprogramming) \n3. Create a clock *without*  these blocks!  Hints: You'll need a few counter variables, a forever loop, and the ability to ``[basic.pause()]``.\n\n\n# Bonus: A Binary Clock \n\nHere's a simple clock that will show time in binary code.  Each column represents a digit of the current 12-hour time. \nThe bottom most LED in each column is the 1's digit, the second from the bottom is the 2's, etc.  The middle column of the display will blink a pattern off and on to indicate each second.\n\n[Click here to open the shared project](https://makecode.microbit.org/_MJqeqei2aFjJ)\n\n```block\nfunction binaryDisplayOf (num: number, col: number) {\n    for (let index = 0; index \u003c= 4; index++) {\n        if (Math.idiv(num, 2 ** index) % 2 == 1) {\n            led.plot(col, 4 - index)\n        } else {\n            led.unplot(col, 4 - index)\n        }\n    }\n}\ninput.onButtonPressed(Button.B, function () {\n    timeanddate.advanceBy(1, timeanddate.TimeUnit.Minutes)\n})\ninput.onButtonPressed(Button.A, function () {\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMM))\n})\ninput.onButtonPressed(Button.AB, function () {\n    timeanddate.advanceBy(15, timeanddate.TimeUnit.Minutes)\n})\nbasic.showString(\"hr:\")\nwhile (!(input.buttonIsPressed(Button.B))) {\n    if (input.buttonIsPressed(Button.A)) {\n        timeanddate.advanceBy(1, timeanddate.TimeUnit.Hours)\n    }\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMM))\n}\nbasic.showString(\"min:\")\nwhile (!(input.buttonIsPressed(Button.B))) {\n    if (input.buttonIsPressed(Button.A)) {\n        timeanddate.advanceBy(1, timeanddate.TimeUnit.Minutes)\n    }\n    basic.showString(timeanddate.time(timeanddate.TimeFormat.HMM))\n}\nlet blink = false\nbasic.forever(function () {\n    timeanddate.numericTime(function (hour, minute, second, month, day, year) {\n        hour = 0 % 12\n        if (hour == 0) {\n            hour = 12\n        }\n        binaryDisplayOf(Math.idiv(hour, 10), 0)\n        binaryDisplayOf(hour % 10, 1)\n        binaryDisplayOf(Math.idiv(minute, 10), 3)\n        binaryDisplayOf(minute % 10, 4)\n    })\n    basic.pause(1000)\n    blink = !(blink)\n    if (blink) {\n        binaryDisplayOf(10, 2)\n    } else {\n        binaryDisplayOf(0, 2)\n    }\n})\n```\n\n# Bonus: A Stopwatch\n\nHere's a simple stopwatch.  \"A\" starts and stops the count. The count will be automatically displayed\nwhen it's stopped, but pressing \"B\" will re-display it.\n\n[Click here to open the shared project](https://makecode.microbit.org/_2MK536dctd0m)\n\n```block\ninput.onButtonPressed(Button.A, function () {\n    running = !(running)\n    if (running) {\n        timeanddate.set24HourTime(0, 0, 0)\n    } else {\n        captured = timeanddate.time(timeanddate.TimeFormat.HHMMSS24hr)\n        basic.showString(captured)\n    }\n})\ninput.onButtonPressed(Button.B, function () {\n    if (!(running)) {\n        basic.showString(captured)\n    }\n})\nlet dotLocation = 0\nlet xy = 0\nlet captured = \"\"\nlet running = false\nrunning = false\nlet coords = [11, 21, 31, 32, 33, 23, 13, 12]\nbasic.forever(function () {\n    if (running) {\n        basic.clearScreen()\n        xy = coords[dotLocation]\n        led.toggle(Math.idiv(xy, 10), xy % 10)\n        basic.pause(1000/8)\n        dotLocation = (dotLocation + 1) % 8\n    } else {\n        basic.showIcon(IconNames.No)\n    }\n})\n```\n\n## Misc Links \u0026 References\n\n- Algorithms used here and Unit tests for them are available on GitHub: https://github.com/bsiever/software-based-RTC-algorithm\n- SparkFun's Guide was used to help develop this package: https://learn.sparkfun.com/tutorials/how-to-create-a-makecode-package-for-microbit/all\n- I develop micro:bit extensions in my spare time to support activities I'm enthusiastic about, like summer camps and science curricula.  You are welcome to become a sponsor of my micro:bit work (one time or recurring payments), which helps offset equipment costs: [here](https://github.com/sponsors/bsiever). Any support at all is greatly appreciated!\n\n## Supported targets\n\n* for PXT/microbit\n\n\n\u003cscript src=\"https://makecode.com/gh-pages-embed.js\"\u003e\u003c/script\u003e\n\u003cscript\u003emakeCodeRender(\"{{ site.makecode.home_url }}\", \"{{ site.github.owner_name }}/{{ site.github.repository_name }}\");\u003c/script\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsiever%2Fmicrobit-pxt-timeanddate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsiever%2Fmicrobit-pxt-timeanddate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsiever%2Fmicrobit-pxt-timeanddate/lists"}