Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
https://msdnshared.blob.core.windows.net/media/2016/05/0640_NinjaAwardTinyGold.pngGold Award Winner
This article is about Clock object in Microsoft Small Basic programming language.
In this article:
What is a Clock
Personal computers have their internal (system) clock to know current date and time.
Clock Object
Clock object provides access to the system clock. This object has properties only (no events, no operations) and they are for read only.
Properties
Clock object has 11 properties below. These properties are for local time. Especially, formats for Date, Time and WeekDay depend on the local language.
- Date - the current system date
- Day - the current day of the month
- ElapsedMilliseconds - the number of milliseconds that have elapsed since 1900
- Hour - the current hour
- Millisecond - the current millisecond
- Minute - the current minute
- Month - the current month
- Second - the current second
- Time - the current system time
- WeekDay - the current day of the week
- Year - the current year
Sample Programs
Simple Demo for Clock Object
Source code:
TextWindow.WriteLine("Clock.Date=" + Clock.Date)
TextWindow.WriteLine("Clock.Day=" + Clock.Day)
TextWindow.WriteLine("Clock.ElapsedMilliseconds=" + Clock.ElapsedMilliseconds)
TextWindow.WriteLine("Clock.Hour=" + Clock.Hour)
TextWindow.WriteLine("Clock.Millisecond=" + Clock.Millisecond)
TextWindow.WriteLine("Clock.Minute=" + Clock.Minute)
TextWindow.WriteLine("Clock.Month=" + Clock.Month)
TextWindow.WriteLine("Clock.Second=" + Clock.Second)
TextWindow.WriteLine("Clock.Time=" + Clock.Time)
TextWindow.WriteLine("Clock.Weekday=" + Clock.WeekDay)
TextWindow.WriteLine("Clock.Year=" + Clock.Year)
Output:
Clock.Date=2016/01/02
Clock.Day=2
Clock.ElapsedMilliseconds=3660761508535.89
Clock.Hour=22
Clock.Millisecond=537
Clock.Minute=11
Clock.Month=1
Clock.Second=48
Clock.Time=22:11:48
Clock.Weekday=土曜日
Clock.Year=2016
Press any key to continue...
Sample Analog Clock
Program ID: SGP929-1. Following picture is the screen shot of this program.
Julian Day
Following code calculates current Julian Day (local time). Julian Day is the elapsed days from the noon on January 1, 4713 BC (Julian calendar).
jd = Clock.ElapsedMilliseconds / 1000 / 3600 / 24 + 2415020.5
See Also
- Small Basic Curriculum: Lesson 2.5: Clock, Desktop, and Dictionary Objects
- Small Basic Reference Documentation: Clock Object
- Small Basic: Dynamic Graphics (practical usage of Clock.ElapsedMilliseconds)
- Small Basic: Timeline for the games (practical usage of Clock.ElapsedMilliseconds)
- Wiki: Small Basic Portal
Other Resources
- Date Calculator – Small Basic Sample Program (blog)
- Chess Clock!!! - Small Basic Featured Program (blog)
- Create a Visually Fun Clock - Small Basic Challenge (blog)
- Challenge of the Month - March 2015 (forum - countdown clock challenge)
- Challenge of the Month - April 2015 (forum - calculate minutes challenge)
- Challenge of the Month - April 2014 (forum - chess clock challenge)
- Challenge of the Month - November 2014 (forum - alarm/world clock challenge)
- Challenge of the Month - February 2013 (forum - visually fun clock challenge)
- Challenge of the Month - November 2013 (forum - Clock curriculum challenge)
- Challenge of the Month - July 2012 (forum - cat's eye clock/sundial challenge)