Anúncio: todos os projetos não comerciais registrados para usar o Earth Engine antes de
15 de abril de 2025 precisam
verificar a qualificação não comercial para manter o acesso ao Earth Engine.
ee.Date.getFraction
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Retorna a fração decorrido da data da unidade especificada (entre 0 e 1).
Uso | Retorna |
---|
Date.getFraction(unit, timeZone) | Ponto flutuante |
Argumento | Tipo | Detalhes |
---|
date | Data | |
unit | String | Pode ser "ano", "mês", "semana", "dia", "hora", "minuto" ou "segundo". |
timeZone | String, padrão: null | O fuso horário (por exemplo, 'America/Los_Angeles'); padrão é UTC. |
Exemplos
Editor de código (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'));
Configuração do Python
Consulte a página
Ambiente Python para informações sobre a API Python e o uso de
geemap
para desenvolvimento interativo.
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'))
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-07-25 UTC.
[null,null,["Última atualização 2025-07-25 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```"]]