ee.Date.getRelative

מחזירה את היחידה שצוינה (מבוססת-0) של התאריך הזה ביחס ליחידה גדולה יותר. לדוגמה, getRelative('day', 'year') מחזירה ערך בין 0 ל-365.

שימושהחזרות
Date.getRelative(unit, inUnit, timeZone)ארוך
ארגומנטסוגפרטים
זה: dateתאריך
unitמחרוזתאחת מהאפשרויות הבאות: 'חודש', 'שבוע', 'יום', 'שעה', 'דקה' או 'שנייה'.
inUnitמחרוזתאחת מהאפשרויות הבאות: 'שנה', 'חודש', 'שבוע', 'יום', 'שעה' או 'דקה'.
timeZoneמחרוזת, ברירת המחדל: nullאזור הזמן (למשל, 'America/Los_Angeles'); ברירת המחדל היא UTC.

דוגמאות

Code Editor‏ (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'));

הגדרת Python

בדף סביבת Python מפורט מידע על Python API ועל השימוש ב-geemap לפיתוח אינטראקטיבי.

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