Объявление : Все некоммерческие проекты, зарегистрированные для использования Earth Engine до
15 апреля 2025 года, должны
подтвердить некоммерческое право на сохранение доступа к Earth Engine.
ee.Date.getFraction
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Возвращает прошедшую часть указанной единицы измерения для данной даты (от 0 до 1).
Использование | Возвраты | Date. getFraction (unit, timeZone ) | Плавать |
Аргумент | Тип | Подробности | это: date | Дата | |
unit | Нить | Один из вариантов: «год», «месяц», «неделя», «день», «час», «минута» или «секунда». |
timeZone | Строка, по умолчанию: null | Часовой пояс (например, «Америка/Лос-Анджелес»); по умолчанию — UTC. |
Примеры
Редактор кода (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'));
Настройка Python
Информацию об API Python и использовании geemap
для интерактивной разработки см. на странице Python Environment .
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'))
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-24 UTC.
[null,null,["Последнее обновление: 2025-07-24 UTC."],[[["\u003cp\u003e\u003ccode\u003eDate.getFraction()\u003c/code\u003e calculates the elapsed fraction of a specified time unit (year, month, week, day, hour, minute, or second) for a given date, returning a value between 0 and 1.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes the date, the desired time unit, and an optional time zone as input (defaulting to UTC if not specified).\u003c/p\u003e\n"],["\u003cp\u003eThe returned value represents the proportion of the specified time unit that has passed for the given date, for instance, 0.5 for 'day' would indicate it's midday.\u003c/p\u003e\n"],["\u003cp\u003eThis function is valuable for tasks like determining the progress through a specific time period, such as calculating the fraction of a year that has elapsed.\u003c/p\u003e\n"]]],[],null,["# ee.Date.getFraction\n\nReturns this date's elapsed fraction of the specified unit (between 0 and 1).\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------|---------|\n| Date.getFraction`(unit, `*timeZone*`)` | Float |\n\n| Argument | Type | Details |\n|--------------|-----------------------|-----------------------------------------------------------------------|\n| this: `date` | Date | |\n| `unit` | String | One of 'year', 'month', 'week', 'day', 'hour', 'minute', or 'second'. |\n| `timeZone` | String, default: null | The time zone (e.g., 'America/Los_Angeles'); defaults to UTC. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nvar date = ee.Date('2021-4-30T07:15:31.24');\n\nprint('Elapsed fraction of a year', date.getFraction('year'));\nprint('Elapsed fraction of a month', date.getFraction('month'));\nprint('Elapsed fraction of a week', date.getFraction('week'));\nprint('Elapsed fraction of a day', date.getFraction('day'));\nprint('Elapsed fraction of an hour', date.getFraction('hour'));\nprint('Elapsed fraction of a minute', date.getFraction('minute'));\nprint('Elapsed fraction of a second', date.getFraction('second'));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\ndate = ee.Date('2021-4-30T07:15:31.24')\n\ndisplay('Elapsed fraction of a year:', date.getFraction('year'))\ndisplay('Elapsed fraction of a month:', date.getFraction('month'))\ndisplay('Elapsed fraction of a week:', date.getFraction('week'))\ndisplay('Elapsed fraction of a day:', date.getFraction('day'))\ndisplay('Elapsed fraction of an hour:', date.getFraction('hour'))\ndisplay('Elapsed fraction of a minute:', date.getFraction('minute'))\ndisplay('Elapsed fraction of a second:', date.getFraction('second'))\n```"]]