Skip to content

Commit 4fa4ab7

Browse files
committed
translated tasks 4 to 6
1 parent ad49621 commit 4fa4ab7

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

Diff for: 1-js/05-data-types/11-date/3-weekday/_js.view/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe("getLocalDay returns the \"european\" weekday", function() {
1+
describe("getLocalDay returnează ziua \"europeană\"", function() {
22
it("3 January 2014 - friday", function() {
33
assert.equal(getLocalDay(new Date(2014, 0, 3)), 5);
44
});

Diff for: 1-js/05-data-types/11-date/4-get-date-ago/_js.view/test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
describe("getDateAgo", function() {
22

3-
it("1 day before 02.01.2015 -> day 1", function() {
3+
it("1 zi înainte de 02.01.2015 -> day 1", function() {
44
assert.equal(getDateAgo(new Date(2015, 0, 2), 1), 1);
55
});
66

77

8-
it("2 days before 02.01.2015 -> day 31", function() {
8+
it("2 zile înainte de 02.01.2015 -> ziua 31", function() {
99
assert.equal(getDateAgo(new Date(2015, 0, 2), 2), 31);
1010
});
1111

12-
it("100 days before 02.01.2015 -> day 24", function() {
12+
it("100 zile înainte de 02.01.2015 -> ziua 24", function() {
1313
assert.equal(getDateAgo(new Date(2015, 0, 2), 100), 24);
1414
});
1515

16-
it("365 days before 02.01.2015 -> day 2", function() {
16+
it("365 zile înainte de 02.01.2015 -> ziua 2", function() {
1717
assert.equal(getDateAgo(new Date(2015, 0, 2), 365), 2);
1818
});
1919

20-
it("does not modify the given date", function() {
20+
it("nu modifică date-ul dat", function() {
2121
let date = new Date(2015, 0, 2);
2222
let dateCopy = new Date(date);
2323
getDateAgo(dateCopy, 100);

Diff for: 1-js/05-data-types/11-date/4-get-date-ago/solution.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The idea is simple: to substract given number of days from `date`:
1+
Ideea este simplă: se scade un anumit număr de zile din `date`:
22

33
```js
44
function getDateAgo(date, days) {
@@ -7,9 +7,9 @@ function getDateAgo(date, days) {
77
}
88
```
99

10-
...But the function should not change `date`. That's an important thing, because the outer code which gives us the date does not expect it to change.
10+
...Dar funcția nu ar trebui să modifice `date`. Acesta este un lucru important, deoarece codul exterior care ne oferă data nu se așteaptă ca aceasta să se schimbe.
1111

12-
To implement it let's clone the date, like this:
12+
Pentru a implementa acest lucru haideŧi să clonăm data, astfel:
1313

1414
```js run demo
1515
function getDateAgo(date, days) {

Diff for: 1-js/05-data-types/11-date/4-get-date-ago/task.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 4
22

33
---
44

5-
# Which day of month was many days ago?
5+
# Ce zi a lunii a fost acum multe zile?
66

7-
Create a function `getDateAgo(date, days)` to return the day of month `days` ago from the `date`.
7+
Creați o funcție `getDateAgo(date, days)` pentru a returna ziua din lună de acum `days` din `date`.
88

9-
For instance, if today is 20th, then `getDateAgo(new Date(), 1)` should be 19th and `getDateAgo(new Date(), 2)` should be 18th.
9+
De exemplu, dacă astăzi este 20, atunci `getDateAgo(new Date(), 1)` ar trebui să fie 19 și `getDateAgo(new Date(), 2)` ar trebui să fie 18.
1010

11-
Should work reliably for `days=365` or more:
11+
Ar trebui să funcționeze în mod fiabil pentru `days=365` sau mai mult:
1212

1313
```js
1414
let date = new Date(2015, 0, 2);
@@ -18,4 +18,4 @@ alert( getDateAgo(date, 2) ); // 31, (31 Dec 2014)
1818
alert( getDateAgo(date, 365) ); // 2, (2 Jan 2014)
1919
```
2020

21-
P.S. The function should not modify the given `date`.
21+
P.S. Funcția nu trebuie să modifice `date`-ul dat.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
describe("getLastDayOfMonth", function() {
2-
it("last day of 01.01.2012 - 31", function() {
2+
it("ultima zi din 01.01.2012 - 31", function() {
33
assert.equal(getLastDayOfMonth(2012, 0), 31);
44
});
55

6-
it("last day of 01.02.2012 - 29 (leap year)", function() {
6+
it("ultima zi din 01.02.2012 - 29 (an bisect)", function() {
77
assert.equal(getLastDayOfMonth(2012, 1), 29);
88
});
99

10-
it("last day of 01.02.2013 - 28", function() {
10+
it("ultima zi din 01.02.2013 - 28", function() {
1111
assert.equal(getLastDayOfMonth(2013, 1), 28);
1212
});
1313
});

Diff for: 1-js/05-data-types/11-date/5-last-day-of-month/solution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Let's create a date using the next month, but pass zero as the day:
1+
Să creăm o dată folosind luna următoare, dar să trecem zero ca zi:
22
```js run demo
33
function getLastDayOfMonth(year, month) {
44
let date = new Date(year, month + 1, 0);
@@ -10,4 +10,4 @@ alert( getLastDayOfMonth(2012, 1) ); // 29
1010
alert( getLastDayOfMonth(2013, 1) ); // 28
1111
```
1212

13-
Normally, dates start from 1, but technically we can pass any number, the date will autoadjust itself. So when we pass 0, then it means "one day before 1st day of the month", in other words: "the last day of the previous month".
13+
În mod normal, datele încep de la 1, dar, din punct de vedere tehnic putem trece orice număr, data se va ajusta singură. Deci când trecem 0, atunci înseamnă "cu o zi înainte de prima zi a lunii", cu alte cuvinte: "ultima zi a lunii precedente".

Diff for: 1-js/05-data-types/11-date/5-last-day-of-month/task.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Last day of month?
5+
# Ultima zi a lunii?
66

7-
Write a function `getLastDayOfMonth(year, month)` that returns the last day of month. Sometimes it is 30th, 31st or even 28/29th for Feb.
7+
Scrieți o funcție `getLastDayOfMonth(year, month)` care să returneze ultima zi a lunii. Uneori este 30, 31 sau chiar 28/29 pentru Feb.
88

9-
Parameters:
9+
Parametrii:
1010

11-
- `year` -- four-digits year, for instance 2012.
12-
- `month` -- month, from 0 to 11.
11+
- `year` -- anul din patru cifre, de exemplu 2012.
12+
- `month` -- luna, de la 0 la 11.
1313

14-
For instance, `getLastDayOfMonth(2012, 1) = 29` (leap year, Feb).
14+
De exemplu, `getLastDayOfMonth(2012, 1) = 29` (an bisect, Feb).

Diff for: 1-js/05-data-types/11-date/6-get-seconds-today/solution.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
To get the number of seconds, we can generate a date using the current day and time 00:00:00, then substract it from "now".
1+
Pentru a obține numărul de secunde, putem genera o dată folosind ziua și ora curentă 00:00:00, apoi să o scădem din "now".
22

3-
The difference is the number of milliseconds from the beginning of the day, that we should divide by 1000 to get seconds:
3+
Diferența este numărul de milisecunde de la începutul zilei, pe care trebuie să-l împărțim la 1000 pentru a obține secundele:
44

55
```js run
66
function getSecondsToday() {
77
let now = new Date();
88

9-
// create an object using the current day/month/year
9+
// creați un obiect folosind ziua/luna/anul curent
1010
let today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
1111

12-
let diff = now - today; // ms difference
13-
return Math.round(diff / 1000); // make seconds
12+
let diff = now - today; // diferența de ms
13+
return Math.round(diff / 1000); // face secunde
1414
}
1515

1616
alert( getSecondsToday() );
1717
```
1818

19-
An alternative solution would be to get hours/minutes/seconds and convert them to seconds:
19+
O soluție alternativă ar fi să se obțină ore/minute/secunde și să se convertească în secunde:
2020

2121
```js run
2222
function getSecondsToday() {

Diff for: 1-js/05-data-types/11-date/6-get-seconds-today/task.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ importance: 5
22

33
---
44

5-
# How many seconds have passed today?
5+
# Câte secunde au trecut astăzi?
66

7-
Write a function `getSecondsToday()` that returns the number of seconds from the beginning of today.
7+
Scrieți o funcție `getSecondsToday()` care returnează numărul de secunde de la începutul zilei de astăzi.
88

9-
For instance, if now were `10:00 am`, and there was no daylight savings shift, then:
9+
De exemplu, dacă acum este `10:00 am`, și nu a fost schimbată ora de vară, atunci:
1010

1111
```js
1212
getSecondsToday() == 36000 // (3600 * 10)
1313
```
1414

15-
The function should work in any day. That is, it should not have a hard-coded value of "today".
15+
Funcția ar trebui să funcționeze în orice zi. Adică, nu ar trebui să aibă o valoare "astăzi" hard-coded.

0 commit comments

Comments
 (0)