{"id":1687,"date":"2024-12-01T21:53:24","date_gmt":"2024-12-02T00:53:24","guid":{"rendered":"https:\/\/martafagundez.com\/codevolution\/?p=1687"},"modified":"2024-12-01T21:53:26","modified_gmt":"2024-12-02T00:53:26","slug":"gestion-de-fechas-en-python-con-la-libreria-pendulum","status":"publish","type":"post","link":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/","title":{"rendered":"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum"},"content":{"rendered":"\n<p>Trabajar con fechas y tiempos en Python puede complicarse, especialmente cuando se trata de manejar <strong>zonas horarias<\/strong>, <strong>c\u00e1lculos de intervalos<\/strong> o <strong>formatos personalizados<\/strong>. <\/p>\n\n\n\n<p>Aunque <code>datetime<\/code> es la biblioteca nativa para este prop\u00f3sito, su uso puede resultar limitado o poco intuitivo en escenarios avanzados.<\/p>\n\n\n\n<p><strong><a href=\"https:\/\/pendulum.eustace.io\/\">Pendulu<\/a><a href=\"https:\/\/pendulum.eustace.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">m<\/a><\/strong> surge como una soluci\u00f3n robusta, extendiendo y mejorando las capacidades de <code>datetime<\/code>. Su enfoque simplificado y sus caracter\u00edsticas avanzadas hacen que trabajar con fechas sea m\u00e1s eficiente y menos propenso a errores.<\/p>\n\n\n\n<p>En este art\u00edculo, exploraremos algunas de las muchas funcionalidades de Pendulum para cubrir casos comunes y avanzados en la gesti\u00f3n de fechas en Python.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"simpletoc-title\">Tabla de contenidos<\/h2>\n<style>html { scroll-behavior: smooth; }<\/style><ul class=\"simpletoc-list\">\n<li><a href=\"#1-crear-y-manipular-fechas\">1. Crear y manipular fechas<\/a>\n\n\n<ul><li>\n<a href=\"#crear-fechas-con-pendulum\">Crear fechas con Pendulum<\/a>\n\n<\/li>\n<li><a href=\"#convertir-cadenas-de-texto-con-pendulumparse\">Convertir cadenas de texto con pendulum.parse<\/a>\n\n<\/li>\n<li><a href=\"#manipular-fechas-con-add-y-subtract\">Manipular fechas con add() y subtract()<\/a>\n\n<\/li>\n<\/ul>\n<li><a href=\"#2-conversiones-de-zonas-horarias\">2. Conversiones de zonas horarias<\/a>\n\n\n<ul><li>\n<a href=\"#cambiar-a-una-zona-horaria-especifica\">Cambiar a una zona horaria espec\u00edfica<\/a>\n\n<\/li>\n<li><a href=\"#convertir-fechas-locales-a-utc\">Convertir fechas locales a UTC<\/a>\n\n<\/li>\n<\/ul>\n<li><a href=\"#3-calculo-de-diferencias-con-diff\">3. C\u00e1lculo de diferencias con diff()<\/a>\n\n<\/li>\n<li><a href=\"#4-diferencias-en-terminos-humanos\">4. Diferencias en t\u00e9rminos humanos<\/a>\n\n\n<ul><li>\n<a href=\"#diferencia-respecto-al-momento-actual\">Diferencia respecto al momento actual<\/a>\n\n<\/li>\n<li><a href=\"#diferencia-entre-dos-fechas-especificas\">Diferencia entre dos fechas espec\u00edficas<\/a>\n\n<\/li>\n<\/ul>\n<li><a href=\"#5-formateo-y-localizacion\">5. Formateo y localizaci\u00f3n<\/a>\n\n\n<ul><li>\n<a href=\"#formateo-personalizado\">Formateo personalizado<\/a>\n\n<\/li>\n<li><a href=\"#localizacion\">Localizaci\u00f3n<\/a>\n\n<\/li>\n<\/ul>\n<li><a href=\"#6-intervalos-e-iteraciones\">6. Intervalos e iteraciones<\/a>\n\n\n<ul><li>\n<a href=\"#rango-de-dias\">Rango de d\u00edas<\/a>\n\n<\/li>\n<li><a href=\"#incrementos-flexibles\">Incrementos flexibles<\/a>\n\n<\/li>\n<\/ul>\n<li><a href=\"#conclusion\">Conclusi\u00f3n<\/a>\n<\/li><\/ul>\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"1-crear-y-manipular-fechas\"><strong>1. Crear y manipular fechas<\/strong><\/h2>\n\n\n<p>Pendulum hace que trabajar con fechas sea simple e intuitivo, ya sea creando fechas desde cero, manipul\u00e1ndolas o interpretando cadenas de texto.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"crear-fechas-con-pendulum\"><strong>Crear fechas con Pendulum<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import pendulum\n\n# Obtener la fecha y hora actuales en UTC\nnow = pendulum.now(&quot;UTC&quot;)\nprint(now)  # Ejemplo: 2024-12-01 23:03:31.244107+00:00\n\n# Crear una fecha y hora espec\u00edficas\nspecific_date = pendulum.datetime(2024, 12, 25, 10, 30, tz=&quot;America\/New_York&quot;)\nprint(specific_date)  # 2024-12-25 10:30:00-05:00\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">import<\/span><span style=\"color: #F6F6F4\"> pendulum<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Obtener la fecha y hora actuales en UTC<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">now <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.now(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">UTC<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(now)  <\/span><span style=\"color: #7B7F8B\"># Ejemplo: 2024-12-01 23:03:31.244107+00:00<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Crear una fecha y hora espec\u00edficas<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">specific_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">25<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">10<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">30<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">tz<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">America\/New_York<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(specific_date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-25 10:30:00-05:00<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"convertir-cadenas-de-texto-con-pendulumparse\"><strong>Convertir cadenas de texto con <code>pendulum.parse<\/code><\/strong><\/h3>\n\n\n<p>El m\u00e9todo <code>parse<\/code> <a href=\"https:\/\/pendulum.eustace.io\/docs\/#parsing\" target=\"_blank\" rel=\"noreferrer noopener\">convierte cadenas de texto en objetos de fecha<\/a>. Soporta autom\u00e1ticamente zonas horarias y formatos est\u00e1ndar.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Convertir una fecha b\u00e1sica\nparsed_date = pendulum.parse(&quot;2024-12-01&quot;)\nprint(parsed_date)  # 2024-12-01 00:00:00+00:00\n\n# Convertir una fecha con zona horaria\nparsed_date_tz = pendulum.parse(&quot;2024-12-01T15:00:00-05:00&quot;)\nprint(parsed_date_tz)  # 2024-12-01 15:00:00-05:00\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Convertir una fecha b\u00e1sica<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">parsed_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.parse(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">2024-12-01<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(parsed_date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-01 00:00:00+00:00<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Convertir una fecha con zona horaria<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">parsed_date_tz <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.parse(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">2024-12-01T15:00:00-05:00<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(parsed_date_tz)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-01 15:00:00-05:00<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"manipular-fechas-con-add-y-subtract\"><strong>Manipular fechas con <code>add()<\/code> y <code>subtract()<\/code><\/strong><\/h3>\n\n\n<p>Pendulum permite <a href=\"https:\/\/pendulum.eustace.io\/docs\/#addition-and-subtraction\" target=\"_blank\" rel=\"noreferrer noopener\">sumar y restar tiempo<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Sumar tiempo\nfuture_date = specific_date.add(days=5, hours=2)\nprint(future_date)  # 2024-12-30 12:30:00-05:00\n\n# Restar tiempo\npast_date = specific_date.subtract(weeks=1, minutes=15)\nprint(past_date)  # 2024-12-18 10:15:00-05:00\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Sumar tiempo<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">future_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> specific_date.add(<\/span><span style=\"color: #FFB86C; font-style: italic\">days<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #BF9EEE\">5<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">hours<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #BF9EEE\">2<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(future_date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-30 12:30:00-05:00<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Restar tiempo<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">past_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> specific_date.subtract(<\/span><span style=\"color: #FFB86C; font-style: italic\">weeks<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">minutes<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #BF9EEE\">15<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(past_date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-18 10:15:00-05:00<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"2-conversiones-de-zonas-horarias\"><strong>2. Conversiones de zonas horarias<\/strong><\/h2>\n\n\n<p>Pendulum facilita la <a href=\"https:\/\/pendulum.eustace.io\/docs\/#timezones\" target=\"_blank\" rel=\"noreferrer noopener\">conversi\u00f3n entre zonas horarias<\/a>, resolviendo problemas comunes relacionados con el manejo del tiempo global.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"cambiar-a-una-zona-horaria-especifica\"><strong>Cambiar a una zona horaria espec\u00edfica<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Convertir una fecha a otra zona horaria\nuy_time = specific_date.in_tz(&quot;America\/Montevideo&quot;)\nprint(uy_time)  # 2024-12-25 12:30:00-03:00\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Convertir una fecha a otra zona horaria<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">uy_time <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> specific_date.in_tz(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">America\/Montevideo<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(uy_time)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-25 12:30:00-03:00<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"convertir-fechas-locales-a-utc\"><strong>Convertir fechas locales a UTC<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"local_date = pendulum.datetime(2024, 12, 1, 10, 0, tz=&quot;America\/New_York&quot;)\nutc_date = local_date.in_tz(&quot;UTC&quot;)\nprint(utc_date)  # 2024-12-01 15:00:00+00:00\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F6F6F4\">local_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">10<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">0<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">tz<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">America\/New_York<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">utc_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> local_date.in_tz(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">UTC<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(utc_date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-01 15:00:00+00:00<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"3-calculo-de-diferencias-con-diff\"><strong>3. C\u00e1lculo de diferencias con <code>diff()<\/code><\/strong><\/h2>\n\n\n<p>Pendulum incluye herramientas intuitivas para calcular <a href=\"https:\/\/pendulum.eustace.io\/docs\/#difference\" target=\"_blank\" rel=\"noreferrer noopener\">diferencias entre fechas<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"start_date = pendulum.datetime(2024, 12, 1)\nend_date = pendulum.datetime(2024, 12, 31)\n\n# Diferencia en d\u00edas\ndays_diff = end_date.diff(start_date).in_days()\nprint(days_diff)  # 30\n\n# Diferencia en horas\nhours_diff = end_date.diff(start_date).in_hours()\nprint(hours_diff)  # 720\n\n# Diferencia en semanas\nweeks_diff = end_date.diff(start_date).in_weeks()\nprint(weeks_diff)  # 4\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F6F6F4\">start_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">end_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">31<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Diferencia en d\u00edas<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">days_diff <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> end_date.diff(start_date).in_days()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(days_diff)  <\/span><span style=\"color: #7B7F8B\"># 30<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Diferencia en horas<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">hours_diff <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> end_date.diff(start_date).in_hours()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(hours_diff)  <\/span><span style=\"color: #7B7F8B\"># 720<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Diferencia en semanas<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">weeks_diff <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> end_date.diff(start_date).in_weeks()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(weeks_diff)  <\/span><span style=\"color: #7B7F8B\"># 4<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"4-diferencias-en-terminos-humanos\"><strong>4. Diferencias en t\u00e9rminos humanos<\/strong><\/h2>\n\n\n<p>El m\u00e9todo <code>diff_for_humans()<\/code> convierte una diferencia de tiempo en una representaci\u00f3n amigable para los humanos. Este m\u00e9todo genera frases como \u00abhace 3 d\u00edas\u00bb o \u00aben 2 semanas\u00bb, dependiendo de si la diferencia de tiempo es pasada o futura.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"diferencia-respecto-al-momento-actual\"><strong>Diferencia respecto al momento actual<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Fecha del momento actual\nprint(pendulum.now().date()) # 2024-12-01\n\n# Hace cu\u00e1nto ocurri\u00f3 algo\npast_date = pendulum.datetime(2024, 11, 25)\nprint(past_date.diff_for_humans())  # &quot;7 days ago&quot;\n\n# Cu\u00e1nto falta para un evento\nfuture_date = pendulum.datetime(2024, 12, 31)\nprint(future_date.diff_for_humans())  # &quot;in 4 weeks&quot;\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Fecha del momento actual<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(pendulum.now().date()) <\/span><span style=\"color: #7B7F8B\"># 2024-12-01<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Hace cu\u00e1nto ocurri\u00f3 algo<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">past_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">11<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">25<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(past_date.diff_for_humans())  <\/span><span style=\"color: #7B7F8B\"># &quot;7 days ago&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Cu\u00e1nto falta para un evento<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">future_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">31<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(future_date.diff_for_humans())  <\/span><span style=\"color: #7B7F8B\"># &quot;in 4 weeks&quot;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"diferencia-entre-dos-fechas-especificas\"><strong>Diferencia entre dos fechas espec\u00edficas<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"start_date = pendulum.datetime(2024, 1, 1)\nend_date = pendulum.datetime(2024, 12, 1)\nprint(start_date.diff_for_humans(end_date)) # &quot;11 months before&quot;\nprint(end_date.diff_for_humans(start_date)) # &quot;11 months after&quot;\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F6F6F4\">start_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">end_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(start_date.diff_for_humans(end_date)) <\/span><span style=\"color: #7B7F8B\"># &quot;11 months before&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(end_date.diff_for_humans(start_date)) <\/span><span style=\"color: #7B7F8B\"># &quot;11 months after&quot;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"5-formateo-y-localizacion\"><strong>5. Formateo y localizaci\u00f3n<\/strong><\/h2>\n\n\n<p>Pendulum facilita el formateo de fechas y soporta m\u00faltiples idiomas, lo que lo hace ideal para proyectos internacionales.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"formateo-personalizado\"><strong>Formateo personalizado<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Formateo b\u00e1sico\nformatted_date = specific_date.format(&quot;YYYY-MM-DD HH:mm:ss&quot;)\nprint(formatted_date)  # 2024-12-25 10:30:00\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Formateo b\u00e1sico<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">formatted_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> specific_date.format(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">YYYY-MM-DD HH:mm:ss<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(formatted_date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-25 10:30:00<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"localizacion\"><strong>Localizaci\u00f3n<\/strong><\/h3>\n\n\n<p>Pendulum puede <a href=\"https:\/\/pendulum.eustace.io\/docs\/#localization\" target=\"_blank\" rel=\"noreferrer noopener\">formatear fechas en varios idiomas<\/a> mediante el par\u00e1metro <code>locale<\/code> del m\u00e9todo <code>format()<\/code>:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Mostrar fecha en espa\u00f1ol\nlocalized_date = specific_date.format(&quot;dddd, D [de] MMMM [de] YYYY&quot;, locale=&quot;es&quot;)\nprint(localized_date)  # mi\u00e9rcoles, 25 de diciembre de 2024\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Mostrar fecha en espa\u00f1ol<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">localized_date <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> specific_date.format(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">dddd, D [de] MMMM [de] YYYY<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">locale<\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">es<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(localized_date)  <\/span><span style=\"color: #7B7F8B\"># mi\u00e9rcoles, 25 de diciembre de 2024<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"6-intervalos-e-iteraciones\"><strong>6. Intervalos e iteraciones<\/strong><\/h2>\n\n\n<p>Pendulum permite definir <a href=\"https:\/\/pendulum.eustace.io\/docs\/#interval\" target=\"_blank\" rel=\"noreferrer noopener\">intervalos<\/a> y recorrer fechas dentro de un <a href=\"https:\/\/pendulum.eustace.io\/docs\/#range\" target=\"_blank\" rel=\"noreferrer noopener\">rango<\/a>.<\/p>\n\n\n\n<p>Las unidades admitidas para un rango son: <code>years<\/code>, <code>months<\/code>, <code>weeks<\/code>, <code>days<\/code>, <code>hours<\/code>, <code>minutes<\/code>, <code>seconds<\/code> y <code>microseconds<\/code>.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"rango-de-dias\"><strong>Rango de d\u00edas<\/strong><\/h3>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Crear un intervalo de fechas\nstart = pendulum.datetime(2024, 12, 1)\nend = pendulum.datetime(2024, 12, 10)\ninterval = pendulum.interval(start, end)\n\n# Iterar sobre el intervalo especificando un rango\nfor date in interval.range('days'):\n    print(date)  # Fechas del 1 al 10 de diciembre\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Crear un intervalo de fechas<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">start <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">1<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">end <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.datetime(<\/span><span style=\"color: #BF9EEE\">2024<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">12<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">10<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">interval <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> pendulum.interval(start, end)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7B7F8B\"># Iterar sobre el intervalo especificando un rango<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F286C4\">for<\/span><span style=\"color: #F6F6F4\"> date <\/span><span style=\"color: #F286C4\">in<\/span><span style=\"color: #F6F6F4\"> interval.range(<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">days<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(date)  <\/span><span style=\"color: #7B7F8B\"># Fechas del 1 al 10 de diciembre<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"incrementos-flexibles\"><strong>Incrementos flexibles<\/strong><\/h3>\n\n\n<p>Pendulum soporta rangos con incrementos personalizados.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 0 16px;font-size:0.8em;width:100%;text-align:left;background-color:#282A36;font-style:italic;color:#f6f6f4\"><span style=\"border-bottom:1px solid rgba(251, 251, 239, 0.2)\">Python<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# Rango con incrementos de 2 d\u00edas\nfor date in interval.range(&quot;days&quot;, 2):\n    print(date)  # 2024-12-01, 2024-12-03, etc.\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7B7F8B\"># Rango con incrementos de 2 d\u00edas<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F286C4\">for<\/span><span style=\"color: #F6F6F4\"> date <\/span><span style=\"color: #F286C4\">in<\/span><span style=\"color: #F6F6F4\"> interval.range(<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">days<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #BF9EEE\">2<\/span><span style=\"color: #F6F6F4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #97E1F1\">print<\/span><span style=\"color: #F6F6F4\">(date)  <\/span><span style=\"color: #7B7F8B\"># 2024-12-01, 2024-12-03, etc.<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusi\u00f3n<\/strong><\/h2>\n\n\n<p>Pendulum es una herramienta <strong>potente y f\u00e1cil de usar<\/strong> para manejar fechas en Python. Con su sintaxis intuitiva y capacidades avanzadas, puedes realizar desde tareas b\u00e1sicas como sumar d\u00edas hasta c\u00e1lculos complejos de intervalos y manejo de zonas horarias.<\/p>\n\n\n\n<p>Si trabajas en proyectos que requieren precisi\u00f3n y claridad en el manejo de fechas, Pendulum es una opci\u00f3n a tener en cuenta. <\/p>\n\n\n\n<p>Puedes explorar m\u00e1s funcionalidades y opciones en <a href=\"https:\/\/pendulum.eustace.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">su sitio web<\/a>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trabajar con fechas y tiempos en Python puede complicarse, especialmente cuando se trata de manejar zonas horarias, c\u00e1lculos de intervalos o formatos personalizados. Aunque datetime&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[39,42,52],"tags":[35],"class_list":["post-1687","post","type-post","status-publish","format-standard","hentry","category-backend","category-desarrollo-web","category-python","tag-back-end"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum - CODEvolution<\/title>\n<meta name=\"description\" content=\"Aprende a gestionar fechas en Python con la librer\u00eda Pendulum con ejemplos pr\u00e1cticos para zonas horarias, intervalos, formateo avanzado y m\u00e1s.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum - CODEvolution\" \/>\n<meta property=\"og:description\" content=\"Aprende a gestionar fechas en Python con la librer\u00eda Pendulum con ejemplos pr\u00e1cticos para zonas horarias, intervalos, formateo avanzado y m\u00e1s.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\" \/>\n<meta property=\"og:site_name\" content=\"CODEvolution\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-02T00:53:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-02T00:53:26+00:00\" \/>\n<meta name=\"author\" content=\"Marta Fag\u00fandez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marta Fag\u00fandez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\"},\"author\":{\"name\":\"Marta Fag\u00fandez\",\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1\"},\"headline\":\"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum\",\"datePublished\":\"2024-12-02T00:53:24+00:00\",\"dateModified\":\"2024-12-02T00:53:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\"},\"wordCount\":453,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1\"},\"keywords\":[\"Back End\"],\"articleSection\":[\"Back End\",\"Desarrollo Web\",\"Python\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\",\"url\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\",\"name\":\"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum - CODEvolution\",\"isPartOf\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#website\"},\"datePublished\":\"2024-12-02T00:53:24+00:00\",\"dateModified\":\"2024-12-02T00:53:26+00:00\",\"description\":\"Aprende a gestionar fechas en Python con la librer\u00eda Pendulum con ejemplos pr\u00e1cticos para zonas horarias, intervalos, formateo avanzado y m\u00e1s.\",\"breadcrumb\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/martafagundez.com\/codevolution\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#website\",\"url\":\"https:\/\/martafagundez.com\/codevolution\/\",\"name\":\"CODEvolution\",\"description\":\"Blog de Marta Fag\u00fandez\",\"publisher\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/martafagundez.com\/codevolution\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1\",\"name\":\"Marta Fag\u00fandez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/martafagundez.com\/codevolution\/wp-content\/uploads\/2023\/08\/marta_fagundez_developer_avatar1.png\",\"contentUrl\":\"https:\/\/martafagundez.com\/codevolution\/wp-content\/uploads\/2023\/08\/marta_fagundez_developer_avatar1.png\",\"width\":603,\"height\":603,\"caption\":\"Marta Fag\u00fandez\"},\"logo\":{\"@id\":\"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/image\/\"},\"description\":\"Aqu\u00ed comparto algunos de mis aprendizajes como desarrolladora web. Si alguno de mis art\u00edculos te ha resultado \u00fatil, me alegrar\u00eda saberlo ;)\",\"sameAs\":[\"https:\/\/martafagundez.com\",\"https:\/\/www.linkedin.com\/in\/martafagundezrodriguez\",\"https:\/\/www.youtube.com\/@martafagundez\"],\"url\":\"https:\/\/martafagundez.com\/codevolution\/author\/marta\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum - CODEvolution","description":"Aprende a gestionar fechas en Python con la librer\u00eda Pendulum con ejemplos pr\u00e1cticos para zonas horarias, intervalos, formateo avanzado y m\u00e1s.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/","og_locale":"es_ES","og_type":"article","og_title":"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum - CODEvolution","og_description":"Aprende a gestionar fechas en Python con la librer\u00eda Pendulum con ejemplos pr\u00e1cticos para zonas horarias, intervalos, formateo avanzado y m\u00e1s.","og_url":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/","og_site_name":"CODEvolution","article_published_time":"2024-12-02T00:53:24+00:00","article_modified_time":"2024-12-02T00:53:26+00:00","author":"Marta Fag\u00fandez","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Marta Fag\u00fandez","Tiempo de lectura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#article","isPartOf":{"@id":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/"},"author":{"name":"Marta Fag\u00fandez","@id":"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1"},"headline":"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum","datePublished":"2024-12-02T00:53:24+00:00","dateModified":"2024-12-02T00:53:26+00:00","mainEntityOfPage":{"@id":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/"},"wordCount":453,"commentCount":0,"publisher":{"@id":"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1"},"keywords":["Back End"],"articleSection":["Back End","Desarrollo Web","Python"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/","url":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/","name":"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum - CODEvolution","isPartOf":{"@id":"https:\/\/martafagundez.com\/codevolution\/#website"},"datePublished":"2024-12-02T00:53:24+00:00","dateModified":"2024-12-02T00:53:26+00:00","description":"Aprende a gestionar fechas en Python con la librer\u00eda Pendulum con ejemplos pr\u00e1cticos para zonas horarias, intervalos, formateo avanzado y m\u00e1s.","breadcrumb":{"@id":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/martafagundez.com\/codevolution\/gestion-de-fechas-en-python-con-la-libreria-pendulum\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/martafagundez.com\/codevolution\/"},{"@type":"ListItem","position":2,"name":"Gesti\u00f3n de Fechas en Python con la Librer\u00eda Pendulum"}]},{"@type":"WebSite","@id":"https:\/\/martafagundez.com\/codevolution\/#website","url":"https:\/\/martafagundez.com\/codevolution\/","name":"CODEvolution","description":"Blog de Marta Fag\u00fandez","publisher":{"@id":"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/martafagundez.com\/codevolution\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":["Person","Organization"],"@id":"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/3e1e66d60048c83d5dff039f53b615e1","name":"Marta Fag\u00fandez","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/image\/","url":"https:\/\/martafagundez.com\/codevolution\/wp-content\/uploads\/2023\/08\/marta_fagundez_developer_avatar1.png","contentUrl":"https:\/\/martafagundez.com\/codevolution\/wp-content\/uploads\/2023\/08\/marta_fagundez_developer_avatar1.png","width":603,"height":603,"caption":"Marta Fag\u00fandez"},"logo":{"@id":"https:\/\/martafagundez.com\/codevolution\/#\/schema\/person\/image\/"},"description":"Aqu\u00ed comparto algunos de mis aprendizajes como desarrolladora web. Si alguno de mis art\u00edculos te ha resultado \u00fatil, me alegrar\u00eda saberlo ;)","sameAs":["https:\/\/martafagundez.com","https:\/\/www.linkedin.com\/in\/martafagundezrodriguez","https:\/\/www.youtube.com\/@martafagundez"],"url":"https:\/\/martafagundez.com\/codevolution\/author\/marta\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/posts\/1687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/comments?post=1687"}],"version-history":[{"count":20,"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/posts\/1687\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/posts\/1687\/revisions\/1707"}],"wp:attachment":[{"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/media?parent=1687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/categories?post=1687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/martafagundez.com\/codevolution\/wp-json\/wp\/v2\/tags?post=1687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}