Skip to content

Commit 508c8eb

Browse files
Merge pull request #174
Date and time
2 parents 8fbebd4 + aafcf3f commit 508c8eb

File tree

22 files changed

+252
-252
lines changed

22 files changed

+252
-252
lines changed

1-js/05-data-types/11-date/1-new-date/solution.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
The `new Date` constructor uses the local time zone. So the only important thing to remember is that months start from zero.
1+
Constructorul `new Date` utilizează fusul orar local. Așadar singurul lucru important de reținut este că lunile încep de la zero.
22

3-
So February has number 1.
3+
Deci Februarie are numărul 1.
44

5-
Here's an example with numbers as date components:
5+
Iată un exemplu cu numere ca și componente ale datei:
66

77
```js run
8-
//new Date(year, month, date, hour, minute, second, millisecond)
8+
//new Date(an, lună, dată, oră, minut, secundă, milisecundă)
99
let d1 = new Date(2012, 1, 20, 3, 12);
1010
alert( d1 );
1111
```
12-
We could also create a date from a string, like this:
12+
Am putea de asemenea să creăm o dată dintr-un șir, în felul următor:
1313

1414
```js run
1515
//new Date(datastring)

1-js/05-data-types/11-date/1-new-date/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ importance: 5
22

33
---
44

5-
# Create a date
5+
# Creați o dată
66

7-
Create a `Date` object for the date: Feb 20, 2012, 3:12am. The time zone is local.
7+
Creați un obiect `Date` pentru data: Feb 20, 2012, 3:12am. Fusul orar este local.
88

9-
Show it using `alert`.
9+
Afișați-o folosind `alert`.

1-js/05-data-types/11-date/2-get-week-day/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The method `date.getDay()` returns the number of the weekday, starting from sunday.
1+
Metoda `date.getDay()` returnează numărul zilei săptămânii, începând de duminică.
22

3-
Let's make an array of weekdays, so that we can get the proper day name by its number:
3+
Să creăm o matrice de zile ale săptămânii, astfel încât să putem obține numele zilei corespunzătoare prin numărul ei:
44

55
```js run demo
66
function getWeekDay(date) {

1-js/05-data-types/11-date/2-get-week-day/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Show a weekday
5+
# Arată o zi a săptămânii
66

7-
Write a function `getWeekDay(date)` to show the weekday in short format: 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'.
7+
Scrieți o funcție `getWeekDay(date)` pentru a afișa ziua săptămânii în format scurt: 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'.
88

9-
For instance:
9+
De exemplu:
1010

1111
```js no-beautify
1212
let date = new Date(2012, 0, 3); // 3 Jan 2012
13-
alert( getWeekDay(date) ); // should output "TU"
13+
alert( getWeekDay(date) ); // ar trebui să iasă "TU"
1414
```

1-js/05-data-types/11-date/3-weekday/_js.view/solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function getLocalDay(date) {
22

33
let day = date.getDay();
44

5-
if (day == 0) { // weekday 0 (sunday) is 7 in european
5+
if (day == 0) { // ziua săptămânii 0 (sunday) este 7 în Europa
66
day = 7;
77
}
88

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

Lines changed: 1 addition & 1 deletion
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
});

1-js/05-data-types/11-date/3-weekday/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# European weekday
5+
# Zi lucrătoare europeană
66

7-
European countries have days of week starting with Monday (number 1), then Tuesday (number 2) and till Sunday (number 7). Write a function `getLocalDay(date)` that returns the "European" day of week for `date`.
7+
Țările europene au zile ale săptămânii care încep cu Monday (numărul 1), apoi Tuesday (numărul 2) și până Sunday (numărul 7). Scrieți o funcție `getLocalDay(date)` care returnează ziua săptămânii "Europene" pentru `date`.
88

99
```js no-beautify
1010
let date = new Date(2012, 0, 3); // 3 Jan 2012
11-
alert( getLocalDay(date) ); // tuesday, should show 2
11+
alert( getLocalDay(date) ); // tuesday, ar trebui să arate 2
1212
```

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

Lines changed: 5 additions & 5 deletions
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);

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

Lines changed: 3 additions & 3 deletions
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) {

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

Lines changed: 5 additions & 5 deletions
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.

0 commit comments

Comments
 (0)