ee.Date.getFraction

Trả về phân số đã trôi qua của ngày này theo đơn vị đã chỉ định (từ 0 đến 1).

Cách sử dụngGiá trị trả về
Date.getFraction(unit, timeZone)Số thực dấu phẩy động
Đối sốLoạiThông tin chi tiết
this: dateNgày
unitChuỗiMột trong các giá trị "năm", "tháng", "tuần", "ngày", "giờ", "phút" hoặc "giây".
timeZoneChuỗi, mặc định: rỗngMúi giờ (ví dụ: 'America/Los_Angeles'); mặc định là UTC.

Ví dụ

Trình soạn thảo mã (JavaScript)

var date = ee.Date('2021-4-30T07:15:31.24');

print('Elapsed fraction of a year', date.getFraction('year'));
print('Elapsed fraction of a month', date.getFraction('month'));
print('Elapsed fraction of a week', date.getFraction('week'));
print('Elapsed fraction of a day', date.getFraction('day'));
print('Elapsed fraction of an hour', date.getFraction('hour'));
print('Elapsed fraction of a minute', date.getFraction('minute'));
print('Elapsed fraction of a second', date.getFraction('second'));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho hoạt động phát triển tương tác.

import ee
import geemap.core as geemap

Colab (Python)

date = ee.Date('2021-4-30T07:15:31.24')

display('Elapsed fraction of a year:', date.getFraction('year'))
display('Elapsed fraction of a month:', date.getFraction('month'))
display('Elapsed fraction of a week:', date.getFraction('week'))
display('Elapsed fraction of a day:', date.getFraction('day'))
display('Elapsed fraction of an hour:', date.getFraction('hour'))
display('Elapsed fraction of a minute:', date.getFraction('minute'))
display('Elapsed fraction of a second:', date.getFraction('second'))