ee.Date.getRelative

Restituisce l'unità specificata (basata su 0) di questa data rispetto a un'unità più grande, ad esempio getRelative('day', 'year') restituisce un valore compreso tra 0 e 365.

UtilizzoResi
Date.getRelative(unit, inUnit, timeZone)Lungo
ArgomentoTipoDettagli
questo: dateData
unitStringaUno dei valori "month", "week", "day", "hour", "minute" o "second".
inUnitStringaUno dei valori "year", "month", "week", "day", "hour" o "minute".
timeZoneStringa, predefinito: nullIl fuso orario (ad es. 'America/Los_Angeles'); il valore predefinito è UTC.

Esempi

Editor di codice (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'));

Configurazione di Python

Per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo, consulta la pagina Ambiente Python.

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'))