You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/05-data-types/11-date/article.md
+26-26
Original file line number
Diff line number
Diff line change
@@ -379,55 +379,55 @@ Motoarele JavaScript moderne efectuează multe optimizări. Acestea ar putea aju
379
379
Marele pachet de articole despre V8 poate fi găsit la <https://mrale.ph>.
380
380
```
381
381
382
-
## Date.parse from a string
382
+
## Date.parse dintr-un șir
383
383
384
-
The method [Date.parse(str)](mdn:js/Date/parse) can read a date from a string.
384
+
Metoda [Date.parse(str)](mdn:js/Date/parse) poate citi o dată dintr-un șir.
385
385
386
-
The string format should be: `YYYY-MM-DDTHH:mm:ss.sssZ`, where:
386
+
Formatul șirului trebuie să fie: `YYYY-MM-DDTHH:mm:ss.sssZ`, unde:
387
387
388
-
- `YYYY-MM-DD` -- is the date: year-month-day.
389
-
- The character `"T"`is used as the delimiter.
390
-
- `HH:mm:ss.sss` -- is the time: hours, minutes, seconds and milliseconds.
391
-
- The optional`'Z'`part denotes the time zone in the format `+-hh:mm`. A single letter`Z`would mean UTC+0.
388
+
- `YYYY-MM-DD` -- este data: an-lună-zi.
389
+
- Caracterul `"T"`este utilizat ca delimitator.
390
+
- `HH:mm:ss.sss` -- este timpul: ore, minute, secunde și milisecunde.
391
+
- Partea opțională`'Z'`denotă fusul orar în formatul `+-hh:mm`. O singură literă`Z`ar însemna UTC+0.
392
392
393
-
Shorter variants are also possible, like`YYYY-MM-DD`or`YYYY-MM`or even`YYYY`.
393
+
Sunt posibile și variante mai scurte, precum`YYYY-MM-DD`sau`YYYY-MM`sau chiar`YYYY`.
394
394
395
-
The call to `Date.parse(str)`parses the string in the given format and returns the timestamp (number of milliseconds from 1 Jan 1970 UTC+0). If the format is invalid, returns`NaN`.
395
+
Apelul la `Date.parse(str)`parsează șirul în formatul dat și returnează timestamp-ul (numărul de milisecunde de la 1 ianuarie 1970 UTC+0). Dacă formatul nu este valid, se returnează`NaN`.
396
396
397
-
For instance:
397
+
De exemplu:
398
398
399
399
```js run
400
400
let ms =Date.parse('2012-01-26T13:51:50.417-07:00');
401
401
402
-
alert(ms); // 1327611110417 (timestamp)
402
+
alert(ms); // 1327611110417 (timestamp)
403
403
```
404
404
405
-
We can instantly create a`newDate`object from the timestamp:
405
+
Putem crea instantaneu un obiect`newDate`din timestamp:
406
406
407
407
```js run
408
408
let date =newDate( Date.parse('2012-01-26T13:51:50.417-07:00') );
409
409
410
410
alert(date);
411
411
```
412
412
413
-
## Summary
413
+
## Sumar
414
414
415
-
- Date and time in JavaScript are represented with the [Date](mdn:js/Date) object. We can't create "only date" or "only time": `Date`objects always carry both.
416
-
- Months are counted from zero (yes, January is a zero month).
417
-
- Days of week in `getDay()`are also counted from zero (that's Sunday).
418
-
- `Date`auto-corrects itself when out-of-range components are set. Good for adding/subtracting days/months/hours.
419
-
- Dates can be subtracted, giving their difference in milliseconds. That's because a `Date`becomes the timestamp when converted to a number.
420
-
- Use`Date.now()`to get the current timestamp fast.
415
+
- Data și ora în JavaScript sunt reprezentate cu obiectul [Date](mdn:js/Date). Nu putem crea "doar data" sau "doar ora": Obiectele `Date`le conțin întotdeauna pe amândouă.
416
+
- Lunile sunt numărate de la zero (da, Ianuarie este o lună zero).
417
+
- Zilele săptămânii în `getDay()`sunt de asemenea numărate de la zero (asta-i Duminică).
418
+
- `Date`se autocorectează atunci când sunt setate componente în afara intervalului. Bună pentru adăugarea/subtragerea zilelor/lunilor/orelor.
419
+
- Datele pot fi sustrase, dând diferența lor în milisecunde. Asta pentru că un `Date`devine timestamp-ul atunci când este convertit într-un număr.
420
+
- Folosiți`Date.now()`pentru a obține rapid timestamp-ul curent.
421
421
422
-
Note that unlike many other systems, timestamps in JavaScript are in milliseconds, not in seconds.
422
+
Rețineți că spre deosebire de multe alte sisteme, timestamp-urile din JavaScript sunt în milisecunde, nu în secunde.
423
423
424
-
Sometimes we need more precise time measurements. JavaScript itself does not have a way to measure time in microseconds (1 millionth of a second), but most environments provide it. For instance, browser has [performance.now()](mdn:api/Performance/now) that gives the number of milliseconds from the start of page loading with microsecond precision (3 digits after the point):
424
+
Uneori avem nevoie de măsurători de timp mai precise. JavaScript în sine nu are o modalitate de a măsura timpul în microsecunde (1 milionime dintr-o secundă), dar majoritatea mediilor o oferă. De exemplu, browserul are [performance.now()](mdn:api/Performance/now) care oferă numărul de milisecunde de la începutul încărcării paginii cu precizie de microsecunde (3 cifre după punct):
425
425
426
426
```js run
427
-
alert(`Loading started ${performance.now()}ms ago`);
428
-
//Something like: "Loading started 34731.26000000001ms ago"
429
-
// .26 is microseconds (260 microseconds)
430
-
//more than 3 digits after the decimal point are precision errors, only the first 3 are correct
427
+
alert(`Încărcarea a început cu ${performance.now()}ms în urmă`);
428
+
//Ceva precum: "Încărcarea a început acum 34731.26000000001ms"
429
+
// .26 reprezintă microsecunde (260 microsecunde)
430
+
//mai mult de 3 cifre după virgulă sunt erori de precizie, doar primele 3 sunt corecte
431
431
```
432
432
433
-
Node.js has `microtime`module and other ways. Technically, almost any device and environment allows to get more precision, it's just not in`Date`.
433
+
Node.js are modulul `microtime`și alte modalități. Tehnic, aproape orice dispozitiv și mediu permite obținerea unei precizii mai mare, doar că nu este în`Date`.
0 commit comments