ee.Date.getRelative

واحد مشخص شده (بر اساس 0) این تاریخ را نسبت به یک واحد بزرگتر برمی گرداند، به عنوان مثال، getRelative('day', 'year') مقداری بین 0 و 365 برمی گرداند.

استفاده برمی گرداند
Date. getRelative (unit, inUnit, timeZone ) طولانی
استدلال تایپ کنید جزئیات
این: date تاریخ
unit رشته یکی از «ماه»، «هفته»، «روز»، «ساعت»، «دقیقه» یا «دوم».
inUnit رشته یکی از «سال»، «ماه»، «هفته»، «روز»، «ساعت» یا «دقیقه».
timeZone رشته، پیش فرض: null منطقه زمانی (به عنوان مثال، "America/Los_Angeles")؛ پیش فرض UTC است.

نمونه ها

ویرایشگر کد (جاوا اسکریپت)

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

راه اندازی پایتون

برای اطلاعات در مورد API پایتون و استفاده از geemap برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.

import ee
import geemap.core as geemap

کولب (پایتون)

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