homework代做 | 代写project – | c++代写 – Spring 2019 homework

Spring 2019 homework

homework代做 | 代写project – | c++代写 –  这个项目是project代写的代写题目

homework代写 代写homework hw代做

Spring 2019 homework 

Using C++, you will implement some of the functionality of the Date object defined in the ECMAScript 2015 Standard (i.e., javascript). https://www.ecma-international.org/ecma-262/9.0/#sec-numbers-and-dates.

A Date object contains a Number indicating a particular instant in time to within a millisecond. Such a Number is called a time value.

Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. It is assumed that there are exactly 86,400,000 milliseconds per day.

The exact moment of midnight at the beginning of 01 January, 1970 UTC is represented by the value +.

Part 1. ( 5 0pts) Write and properly document the following functions:

  1. Day(t) Section 20.3.1.
  2. TimeWithinDay(t) Section 20.3.1.
  3. DaysInYear(y) Section 20.3.1.
  4. DaysFromYear(y) Section 20.3.1.
  5. TimeFromYear(y) Section 20.3.1.
  6. YearFromTime(t) Section 20.3.1.3 (Harder than the rest of the functions)
  7. InLeapYear(t) Section 20.3.1.
  8. DayWithinYear(t) Section 20.3.1.
  9. MonthFromTime(t) Section 20.3.1.
  10. DateFromTime(t) Section 20.3.1.

NOTES:

  1. You need to include the following files: iostream and cmath.
  2. Time in ms should be defined as a long long int.
  3. Days, months and years should be defined as integers.
  4. Define a global constant msPerDay using the following syntax above main: const long long int msPerDay = 86400000;
  5. All the functions including the main function should be written in a single file.
  6. Use static_cast(value) to convert a long long int value into an integer value.
  7. Each function must have a comment block that explains the input, output and description of the function. Example: ////////////////////////// // Function: Return the month within the year corresponding to the input time. // 0 specifies Jan, 1 specifies Feb, etc. // Input: long long int – ms since 1/1/ // Output: int – A month number in the range 0 through 11, inclusive. //////////////////////////

Part 2. ( 3 0 pts) Write a function that prints the date in the YYYY-MM-DDTHH:mm:ss format. The input to the function should be a time value in ms from Jan 1, 1970. https://www.ecma-international.org/ecma-262/6.0/#sec-date-time-string- format

Where the fields are as follows: YYYY is the decimal digits of the year 0000 to 9999 in the Gregorian calendar.

  • “-” (hyphen) appears literally twice in the string. MM is the month of the year from 01 (January) to 12 (December). DD is the day of the month from 01 to 31. T “T” appears literally in the string, to indicate the beginning of the time element. HH is the number of complete hours that have passed since midnight as two decimal digits from 00 to 24. : “:” (colon) appears literally twice in the string. mm is the number of complete minutes since the start of the hour as two decimal digits from 00 to 59. ss is the number of complete seconds since the start of the minute as two decimal digits from 00 to 59.

Part 3. ( 2 0pts) Write and document a simple main program to test your functions. Your main program should hard code the calls to the functions and have meaningful/helpful output messages (see example below). Make sure to code enough test cases to make sure all your functions work. For example, a very small fraction of your main program could look something like the following

int main(){

cout    <<  "Is 1970    a   leap    year?   "   <<  InLeapYear(TimeFromYear(1970))  <<  ",  correct answer  =   false"  <<  endl;
cout    <<  "Is 1971    a   leap    year?   "   <<  InLeapYear(TimeFromYear(1971))  <<",    correct answer  =   false"  <<  endl;
cout    <<  "Is 1972    a   leap    year?   "   <<  InLeapYear(TimeFromYear(1972))  <<  ",  correct answer  =   true"   <<  endl;
cout    <<  "Is 1973    a   leap    year?   "   <<  InLeapYear(TimeFromYear(1973))  <<  ",  correct answer  =   false"  <<  endl;
cout    <<  "Is 19 68    a  leap    year?   "   <<  InLeapYear(TimeFromYear(19 68 ))    <<  ",  correct answer  =   true"   <<  endl;

return 0; }

The output of this program should be: Is 1970 a leap year? 0, correct answer = false Is 1971 a leap year? 0, correct answer = false Is 1972 a leap year? 1, correct answer = true Is 1973 a leap year? 0, correct answer = false Is 1968 a leap year? 1, correct answer = true

Submission Instructions You must make a CLion project called “hw1” under your SVN homework directory. Check your homework into SVN.