geetools.Date#

Extra methods for the ee.Date class.

Package Contents#

Classes#

DateAccessor

Toolbox for the ee.Date class.

Attributes#

EE_EPOCH

class geetools.Date.DateAccessor(obj)[source]#

Toolbox for the ee.Date class.

Initialize the Date class.

Parameters:

obj (ee.Date) –

static check_unit(unit)[source]#

Check if the provided value is a valid time unit.

Parameters:

unit (str) –

Return type:

None

classmethod fromDOY(doy, year)[source]#

Create a date from a day of year and a year.

Parameters:
  • doy (int) – The day of year.

  • year (int) – The year.

Returns:

The date as a ee.Date object.

Return type:

ee.Date

Examples

import ee, geetools

ee.Initialize()

d = ee.Date.geetools.fromDOY(1, 2020)
d.getInfo()
classmethod fromEpoch(number, unit='day')[source]#

Set an the number of units since epoch (1970-01-01).

Parameters:
  • number (int) – The number of units since the epoch.

  • unit (str) – The unit to return the number of. One of: second, minute, hour, day, month, year.

Returns:

The date as a ee.Date object.

Return type:

ee.Date

Examples

import ee, geetools

ee.Initialize()

d = ee.Date.geetools.fromEpoch(49, 'year')
d.getInfo()
getUnitSinceEpoch(unit='day')[source]#

Get the number of units since epoch (1970-01-01).

Parameters:

unit (str) – The unit to return the number of. One of: second, minute, hour, day, month, year.

Returns:

The number of units since the epoch.

Return type:

ee.Number

Examples

import ee, geetools

ee.Initialize()

d = ee.Date('2020-01-01').geetools.getUnitSinceEpoch('year')
d.getInfo()
isLeap()[source]#

Check if the year of the date is a leap year.

Returns:

1 if the year is a leap year, 0 otherwise.

Return type:

ee.Number

Examples

import ee, geetools

ee.Initialize()

d = ee.Date('2020-01-01').geetools.isLeap()
d.getInfo()
to_datetime()[source]#

Convert a ee.Date to a datetime.datetime.

Returns:

The datetime.datetime representation of the ee.Date.

Return type:

datetime.datetime

Examples

import ee, geetools

ee.Initialize()

d = ee.Date('2020-01-01').geetools.toDatetime()
d.strftime('%Y-%m-%d')
geetools.Date.EE_EPOCH[source]#