Concept of time in javascript

Assignment Help JAVA Programming
Reference no: EM13759070

The Concept of Time in JavaScript

In JavaScript a time is dened as a Date Object. Each date object stores its state as a time value,
which is a primitive number that encodes a date as milliseconds since 1 January 1970 00:00:00 UTC.
Thus, a date later than 1 January 1970 00:00:00 UTC will have a positive time value, whereas an
earlier date will have a negative time value. On the basis of the common timeline (which we all live
on), the distance between any two dates can be calculated using their time values in milliseconds.
Figure 1 illustrates the concept, where C is a date earlier than 1 January 1970 00:00:00 UTC, and
A and B are later with B being further than A.
1https://www.rio2016.com/en
CSC1401 Assignment 1 Specication { Days-To-Go 2
Figure 1: The Dierence Between Two Date Instances
Functional Requirements
Constants and Variables
Within the script section, create constants and variables following professional conventions and
initialise them using right values. Some constants and variables have been suggested in the following
tables. You should create more when necessary.
Table 1: Constants
Description Value
Number of milliseconds in a day 1000*60*60*24
Number of milliseconds in an hour 1000*60*60
Number of milliseconds in a minute 1000*60
Number of milliseconds in a second 1000
Table 2: Variables
Description Initialising value description Type
Name of the event The name of Rio 2016 Olympic Game String
Year of the event The year of Rio 2016 Olympic Game Number
Month of the event The month of Rio 2016 Olympic Game Number

Day of the event The day of Rio 2016 Olympic Game Number Calculation

1. Create a Date object for the date of the event by using the variables created previously.
Send the object constructor the variables (not values) for year, month, and day of the
event;
Mind the order of arguments sent to the constructor;
Note that month numbers begin at 0 for January, 1 for February, and so on;

2. Create a Date object for the current time.
No arguments need to be supplied to the constructor.

3. Calculate the dierence between the current time and the event time:
CSC1401 Assignment 1 Specication { Days-To-Go 3
Use the getTime() member function to get a Date object's time value in milliseconds
Deduct the time value of current time by using the value of event time.

4. Calculate the number of days to the event:
Divide the time value dierence by the number of milliseconds in a day.
Use the Math.
oor() function to reduce the result number to an integer.

5. Calculate the number of hours, minutes, and seconds in the remaining time value:
(a) Mod the time value dierence by the number of milliseconds in a day;
(b) Divide the mod result by the number of milliseconds in an hour;
(c) Use the Math.
oor() function to reduce the number to an integer for the number of
hours;
(d) Repeat Steps (a) to (c) to calculate the number of minutes and seconds. You may need
to update the calculating formula accordingly.
Presentation
Figure 2: Illustration of the Output
Figure 2 shows a sample output when running the \Days-
To-Go" program. Note that
- the information should be displayed using the alert()
function;
- wherever possible you should use variables in expres-
sions instead of explicit values (e.g., literals and num-
bers), for example, using the variable created for the
event name instead of a string value of \RIO 2016";
- the layout of output may vary depending on web
browsers.
Testing
Test your program by comparing its calculating results to the Days-To-Go feature on the ocial
website of Rio 2016 (https://www.rio2016.com/en). Note that due to dierent locality settings on
your computer and the Rio 2016 server, your calculation result could be slightly dierent from that
shown on the Rio 2016 website. For example, in a test when my program said \521 DAYS" to go,
the Rio 2016 website showed \522 DAYS" { Australia is in almost one day ahead of Rio de Janeiro.
Such a dierence is not an error and is acceptable.
Non-functional Requirements
Structure of the Source Code
- All code should appear in the script section in the head of the HTML document.
CSC1401 Assignment 1 Specication { Days-To-Go 4
- Do not write any code in the HTML body. All functionality are delivered by JavaScript.
- In the script order your code as follows:
(a) Constants;
(b) Variables and objects (declared and initialised);
(c) Other statements.
Comments
- You are required to add at least three comments to the source code.
- Do not comment every single line, instead, comment on blocks of code with a common purpose.
- Do not simply translate the syntax into English for comments, instead, describe the purpose
of blocks of code.
Submission
What You Need to Submit { Two Files
For a complete submission you need to submit two les as specied below. You can submit them
individually or compress them and submit a common .zip (or .rar) le. The assignment submission
system will accept only the les with extensions specied in this section.

1. Statement of Completeness in a le saved in .doc, .docx, .odt, .rtf or .txt format in 200-300
of your own words describes:
- The state of your assignment, such as, any known functionality that has not been
implemented, etc. (It is expected that most people will implement all of the functionality
of this assignment.)
- Problems encountered, such as, any problems that you encountered during the as-
signment work and how you dealt with them;
- Re
ection, such as, any lessons learnt in doing the assignment and suggestions to future
programming work.

2. The program in a le saved with an .html extension contains the source code implemented
following the functional and non-functional requirements.
Late Submission and Extension Request
Please refer to USQ Policy Library - Assessment Procedure for information on the late submission
policy and USQ Policy Library - Assessment of Compassionate and Compelling Circumstances
Procedure for considerable special circumstances in extension request.
The Extension Request Form is available on the course's StudyDesk. Should you need to request
an extension please ll the form and email it to the Course Examiner with supportive documents
(e.g., medical certicate or endorsement letter from supervisor in workplace) prior to the due
date . Please note that any requests without supportive documents will be declined
straigthway without consideration.
CSC1401 Assignment 1 Specication { Days-To-Go 5
Marking Criteria
The assignment will be marked out of 16 and scaled down to a grade out of 8. Table 3 presents the
marking criteria. If all criteria are satised you will receive 16 marks. If not all criteria are met,
part marks may be given. Check your own submission against these criteria before you submit.
Table 3: Marking Criteria
ID REQUIREMENTS MARK
Statement of Completeness
1 The statement is in appropriate length of 200-300 of student's own words 1
2 The \State of assignment" re
ects the true state of completeness 1
3 The \Problems encountered" discusses problems and dealing strategies 1
4 The \re
ection" discusses learnt lessons and reasonable suggestions 1
Subtotal 4
Functional Requirements
5 The program is running without any errors 1
6 All constants and variables are declared and initialised appropriately before use 1
7 The event's Date object is created correctly 1
8 The dierence between two times (the event and now) is calculated using appropriate strategy 1
9 The number of days to go to the event is calculated correctly 1
10 The number of hours is calculated correctly 1
11 The number of minutes and seconds are calculated correctly 1
12 The calculating result is displaying appropriately 1
Subtotal 8
Non-functional Requirements
13 The program has a complete structure including all head, body, script sections 1
dened by appropriate tags
14 Identiers of variables and constants are following professional conventions 1
15 Constants and variables are used in calculation and expression instead of explicit values 1
16 At least three comments are added to describe the purpose of blocks of code 1
Subtotal 4
TOTAL 16

Reference no: EM13759070

Questions Cloud

What types of conflict you saw in one of weeks reading : Identify what types of conflict you saw in one of this week's reading assignments. Give specific examples as support for each conflict you identified.
Find the strategic plan of an organization : Find the strategic plan of an organization and analyze and discuss the elements of the plan.
Management information systems course : You have just completed ten (10) weeks of an introduction to management information systems course. Imagine you have been asked to create a one (1) day training course that highlights the important elements of what you have just learned within the..
Identify emerging it trends through scholarly : Identify emerging IT trends through scholarly and/or trade literature. Understand the impact of innovative IT solutions on business
Concept of time in javascript : In JavaScript a time is dened as a Date Object. Each date object stores its state as a time value,which is a primitive number that encodes a date.
Identify the project-what is it supposed to do : Create an entire SDLC process that will bring added value to a business. Identify the project-what is it supposed to do? Determine the methodology to be used; describe, in detail, why you chose this methodology
Find the transaction impact the accounting equation : Suppose your company sold $25,000 in merchandise to a customer for cash. How does this transaction impact the accounting equation?
Function of an ecosystem : Investigate the biotic and abiotic structure and function of an ecosystem and investigate how ecosystems recover from disturbance naturally and through human restoration.
Explain the limited aspect of electrical engineering : Write a 500-word DRAFT that focuses on a limited aspect of Electrical engineering's essay: A pattern or series of patterns, A key paragraph, how it's structured and how it works.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Critics of american often that teacher''s unions represent

Which organization has proposed a set of standards for both elementary level and secondary-level teachers? According to the latest info.,  teachers will be most needed in which of the following areas: Critics of American often argue that teacher's un..

  Java application that calculates the body mass index

Write a Java application that calculates and displays the body mass index (BMI) for N people

  Design a class named linearequation

(Algebra: 2 X 2 linear equations) Design a class named LinearEquation for a 2 X 2 system of linear equations.

  Write an application calccircumference

Write an application (CalcCircumference) that inputs from the user the radius of a circle as an integer and prints the circle's diameter, circumference and area using the floating-point value 3.14159 for ?.

  Design a java program that simulates a slot machine

Instead of displaying images, the program will randomly select a word from the following list: Cherries, Oranges, Plums, Bars, and Bells. The program will select and display a word from this list three times.

  Modify your server to make it multithreaded your server

modify your server to make it multithreaded. your server should allow more than one client to connect and request

  Write a java program to implement the finite field

Write a program called "GF2.java" to implement the finite field GF(p n ) where p is a prime number and n is a positive integer.  You also need to write four methods to realize "+", "-", "´", and "/".

  We will simulate a very simple network by having a process

we will simulate a very simple network by having a process correspond to a node in the network and files correspond to

  Savingsaccount and bankaccount objects

The only differences between SavingsAccount and BankAccount objects is that SavingsAccount have an interest rate and can compute interest when necessary. Add an instance variable and a method to SavingsAccount to allow for these items.

  Traditionally-nutrition programs were targeted to indigent

Traditionally, nutrition programs were targeted to the indigent and poor populations in developing countries. Many of today's Americans are malnourished also, but they are glutted with a wealth of unhealthy foods and require a multidisciplinary appro..

  Create a form that contains a guessing game

Create a Form that contains a guessing game with five RadioButtons numbered 1 through 5.  Randomly choose one of the RadioButtons as the winning button.  When the user clicks a RadioButton, display a message indicating whether the user is correct.

  Implement a personal scheduler windows application

Implement a personal scheduler Windows application - Entries can be enabled and disabled: Enabled schedule entries appear dark in the main window, and disabled entries appear grayed out in the list.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd