# Date Formats

Think of how many different formats you know of to format today's date: 

- 

Yikes! 

# Date, Time, and Datetime

Date/time data are data that conveys information about, you guessed it, date and/or time! There are three relevant data types when we talk about date/time data:

1. Date - only has the date (e.g. 2020-05-15) 
2. Time - only has the time (e.g. 20:45:00) 
3. Datetime - has both the date and time (e.g. 2020-05-15 20:45:00)

# `Lubridate`

![Artwork by @allisonhorst](https://cdn.myportfolio.com/45214904-6a61-4e23-98d6-b140f8654a40/79a12c01-0cc1-4643-b1e7-8ce8cafc947b_rw_1920.png?h=a3760f3882e735d7065627fc060714ce){width=50%}

```{r}
#| warning: FALSE
#| message: FALSE
#LOAD PACKAGES 
library(tidyverse)
library(lubridate)
```

# Standard Date Format

The `ymd()` function transforms data in all kinds of different formats into a standardized date format displaying year, then month, then day. 

```{r}
ymd("06 02 04")
ymd("06/02/04")
ymd("20060204")  # works as well
ymd("2006 2 4")
ymd(060204)  # works with numbers
```

`mdy()` (month day year) and `dmy()` (day month year) formats also exist. 

```{r}
ymd_hms("2020-04-01 10:30:13")
ymd_hm("2020/04/01 10.30")
```

# Solar Data

Shoal Marine Lab (SML) is a remote field station located on Appledore Island, Maine jointly operated by Cornell University and the University of New Hampshire. The island is powered primarily by solar power. 

```{r}
#read in Data
power <- read.csv("power.csv")
```

What format is the date in? 

:::callout-warning
What happens if we try to make a line plot with the date in this format? 

```{r}
power %>% 
  ggplot(aes(x=Date, y=power_kW)) +
  geom_line()
```
Yikes!
:::

We need to put it in standardized date format first:

```{r}

```  

Standardized Format helps us to create time series plots very easily! 

```{r}

```

# Picking out information

![Artwork by @allisonhorst](https://cdn.myportfolio.com/45214904-6a61-4e23-98d6-b140f8654a40/3017cf57-d7d9-4f73-9b66-f2be0ebf2489_rw_1920.png?h=2cdd179bc087c56b43f8aa6ea849ca1a){width=50%}

Sometimes we need to pick out year, month, date so we can filter, sort, etc. 

```{r}

```

Suppose we only want the time series plot for June 1: 

```{r}


```

# Portal Data

The Portal Project is a long-term ecological study being conducted near Portal, AZ. Since 1977, the site has been used to study the interactions among rodents, ants and plants and their respective responses to climate.

```{r}
#LOAD DATA
portal_rodent <- read.csv("https://github.com/weecology/PortalData/raw/main/Rodents/Portal_rodent.csv")
```

Unfortunately, because the information about datetime is divided up into different columns, R does not recognize it as date/time data. What we need to do is combine and convert all of these columns into datetime. To do this, we can use the function `make_datetime()`

```{r}

```

