ee.Date.getRelative
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Zwraca określoną jednostkę (zliczaną od 0) tej daty w stosunku do większej jednostki, np. getRelative(„day”, „year”) zwraca wartość od 0 do 365.
Wykorzystanie | Zwroty |
---|
Date.getRelative(unit, inUnit, timeZone) | Długie |
Argument | Typ | Szczegóły |
---|
to: date | Data | |
unit | Ciąg znaków | Jedna z wartości „month” (miesiąc), „week” (tydzień), „day” (dzień), „hour” (godzina), „minute” (minut) lub „second” (sekunda). |
inUnit | Ciąg znaków | Jedna z wartości „year” (rok), „month” (miesiąc), „week” (tydzień), „day” (dzień), „hour” (godzina) lub „minute” ( minuta). |
timeZone | Ciąg tekstowy, domyślnie: null | Strefa czasowa (np. 'America/Los_Angeles'); domyślnie ustawiona jest strefa czasowa UTC. |
Przykłady
Edytor kodu (JavaScript)
var date = ee.Date('2021-4-30T07:15:31.24');
print('0-based month of year', date.getRelative('month', 'year'));
print('0-based week of year', date.getRelative('week', 'year'));
print('0-based day of year', date.getRelative('day', 'year'));
print('0-based day of month', date.getRelative('day', 'month'));
print('0-based minute of day', date.getRelative('minute', 'day'));
print('0-based second of minute', date.getRelative('second', 'minute'));
// 0 is returned when unit argument is larger than inUnit argument.
print('0-based year of month (bad form)', date.getRelative('year', 'month'));
Konfiguracja Pythona
Informacje o interfejsie Python API i o używaniu pakietu geemap
do programowania interaktywnego znajdziesz na stronie
Python Environment.
import ee
import geemap.core as geemap
Colab (Python)
date = ee.Date('2021-4-30T07:15:31.24')
display('0-based month of year:', date.getRelative('month', 'year'))
display('0-based week of year:', date.getRelative('week', 'year'))
display('0-based day of year:', date.getRelative('day', 'year'))
display('0-based day of month:', date.getRelative('day', 'month'))
display('0-based minute of day:', date.getRelative('minute', 'day'))
display('0-based second of minute:', date.getRelative('second', 'minute'))
# 0 is returned when unit argument is larger than inUnit argument.
display('0-based year of month (bad form):', date.getRelative('year', 'month'))
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-25 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-25 UTC."],[],[],null,[]]